From a1dfcc3c035f1b4a74874c9713681412f9cfa95c Mon Sep 17 00:00:00 2001 From: Dennis Gloss Date: Sun, 26 Dec 2021 16:49:47 +0300 Subject: [PATCH] fix sending all amount bug --- txutil/create.go | 2 +- wallet/generate.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/txutil/create.go b/txutil/create.go index 75b29a0..101c38b 100644 --- a/txutil/create.go +++ b/txutil/create.go @@ -173,7 +173,7 @@ func getAddressesToWithdrawFrom(params CreateParams) ([]address, error){ } addrsToWithdrawFrom = append(addrsToWithdrawFrom, address{Address: addr, privateKey: pkInfo.key}) satoshiSum += addr.Balance - if !params.SendAll && satoshiSum > params.fullCost() { + if !params.SendAll && satoshiSum >= params.fullCost() { return addrsToWithdrawFrom, nil } } diff --git a/wallet/generate.go b/wallet/generate.go index 8fb4479..b7fa4b2 100644 --- a/wallet/generate.go +++ b/wallet/generate.go @@ -18,6 +18,11 @@ func New(net netchain.Net) (privateKeyWif, bitcoinAddress string) { return wif.String(), addr.EncodeAddress() } +func NewAddress(net netchain.Net) string { + _, address := New(net) + return address +} + func check(err error) { if err != nil { log.Fatal(err)