Skip to content

Commit

Permalink
Merge pull request gcash#432 from gcash/pubkey-utxos
Browse files Browse the repository at this point in the history
[Bug] Return pubkey outputs in pb.bchrpc.GetAddressUnspentOutputs
  • Loading branch information
cpacia authored Dec 9, 2020
2 parents ac37349 + 183d443 commit 0e0e371
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bchrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,17 @@ func (s *GrpcServer) GetAddressUnspentOutputs(ctx context.Context, req *pb.GetAd
continue
}

if addrs[0].EncodeAddress() == addr.EncodeAddress() {
matchAddr := ""

switch typedAddr := addrs[0].(type) {
case *bchutil.AddressPubKeyHash, *bchutil.AddressScriptHash:
matchAddr = addrs[0].EncodeAddress()

case *bchutil.AddressPubKey:
matchAddr = typedAddr.AddressPubKeyHash().EncodeAddress()
}

if matchAddr == addr.EncodeAddress() {
utxo := &pb.UnspentOutput{
Outpoint: &pb.Transaction_Input_Outpoint{
Hash: txHash.CloneBytes(),
Expand Down

0 comments on commit 0e0e371

Please sign in to comment.