mirror of
https://github.com/LBRYFoundation/lbcwallet.git
synced 2025-08-23 17:47:29 +00:00
AddressUsed: try all addresses in a transaction
This commit is contained in:
parent
d9a3f4324c
commit
a75ec902e8
1 changed files with 6 additions and 8 deletions
14
account.go
14
account.go
|
@ -21,7 +21,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcscript"
|
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwallet/tx"
|
"github.com/conformal/btcwallet/tx"
|
||||||
"github.com/conformal/btcwallet/wallet"
|
"github.com/conformal/btcwallet/wallet"
|
||||||
|
@ -118,16 +117,15 @@ func (a *Account) AddressUsed(addr btcutil.Address) bool {
|
||||||
|
|
||||||
// Extract address from pkScript. We currently only care
|
// Extract address from pkScript. We currently only care
|
||||||
// about P2PKH addresses.
|
// about P2PKH addresses.
|
||||||
sc, addrs, _, err := txout.Addresses(cfg.Net())
|
_, addrs, _, err := txout.Addresses(cfg.Net())
|
||||||
switch {
|
if err != nil {
|
||||||
case err != nil:
|
|
||||||
continue
|
|
||||||
case sc != btcscript.PubKeyHashTy:
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if bytes.Equal(addrs[0].ScriptAddress(), pkHash) {
|
for _, a := range addrs {
|
||||||
return true
|
if bytes.Equal(a.ScriptAddress(), pkHash) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Reference in a new issue