Skip to content

Commit

Permalink
[#77] Fix unhandled error in sign methods
Browse files Browse the repository at this point in the history
  • Loading branch information
placer14 committed Apr 9, 2019
1 parent 00a64ca commit 54a89db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions bitcoin/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"time"

"github.com/btcsuite/btcd/chaincfg"

"github.com/OpenBazaar/spvwallet"
wi "github.com/OpenBazaar/wallet-interface"
"github.com/btcsuite/btcd/blockchain"
Expand Down Expand Up @@ -297,10 +298,13 @@ func (w *BitcoinWallet) sweepAddress(ins []wi.TransactionInput, address *btc.Add
// Sign tx
privKey, err := key.ECPrivKey()
if err != nil {
return nil, err
return nil, fmt.Errorf("retrieving private key: %s", err.Error())
}
pk := privKey.PubKey().SerializeCompressed()
addressPub, err := btc.NewAddressPubKey(pk, w.params)
if err != nil {
return nil, fmt.Errorf("generating address pub key: %s", err.Error())
}

getKey := txscript.KeyClosure(func(addr btc.Address) (*btcec.PrivateKey, bool, error) {
if addressPub.EncodeAddress() == addr.EncodeAddress() {
Expand Down
8 changes: 6 additions & 2 deletions bitcoincash/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"time"

"github.com/btcsuite/btcd/chaincfg"

"github.com/OpenBazaar/spvwallet"
wi "github.com/OpenBazaar/wallet-interface"
"github.com/btcsuite/btcd/blockchain"
Expand Down Expand Up @@ -303,10 +304,13 @@ func (w *BitcoinCashWallet) sweepAddress(ins []wi.TransactionInput, address *btc
// Sign tx
privKey, err := key.ECPrivKey()
if err != nil {
return nil, err
return nil, fmt.Errorf("retrieving private key: %s", err.Error())
}
pk := privKey.PubKey().SerializeCompressed()
addressPub, err := btc.NewAddressPubKey(pk, w.params)
if err != nil {
return nil, fmt.Errorf("generating address pub key: %s", err.Error())
}

getKey := txscript.KeyClosure(func(addr btc.Address) (*btcec.PrivateKey, bool, error) {
if addressPub.EncodeAddress() == addr.EncodeAddress() {
Expand Down
8 changes: 6 additions & 2 deletions litecoin/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"time"

"github.com/btcsuite/btcd/chaincfg"

"github.com/OpenBazaar/spvwallet"
wi "github.com/OpenBazaar/wallet-interface"
"github.com/btcsuite/btcd/blockchain"
Expand Down Expand Up @@ -302,10 +303,13 @@ func (w *LitecoinWallet) sweepAddress(ins []wi.TransactionInput, address *btc.Ad
// Sign tx
privKey, err := key.ECPrivKey()
if err != nil {
return nil, err
return nil, fmt.Errorf("retrieving private key: %s", err.Error())
}
pk := privKey.PubKey().SerializeCompressed()
addressPub, err := btc.NewAddressPubKey(pk, w.params)
if err != nil {
return nil, fmt.Errorf("generating address pub key: %s", err.Error())
}

getKey := txscript.KeyClosure(func(addr btc.Address) (*btcec.PrivateKey, bool, error) {
if addressPub.EncodeAddress() == addr.EncodeAddress() {
Expand Down

0 comments on commit 54a89db

Please sign in to comment.