fix: scan v1

This commit is contained in:
Trinity 2025-11-07 15:07:35 +07:00
parent 3ab2b57835
commit a9fe28d5ea

View File

@ -744,23 +744,38 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
continue continue
} }
address := "" pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey)
if req.Version == 0 { if err != nil {
address = base58.Encode(childKey.PublicKey) return nil, err
} else { }
pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey) pkHash := HashPubkey(pkPoint)
if err != nil { ownerLock := &nockchain.NockchainLock{
return nil, err KeysRequired: 1,
} Pubkeys: []string{crypto.Tip5HashToBase58(pkHash)},
pkHash := HashPubkey(pkPoint)
address = crypto.Tip5HashToBase58(pkHash)
} }
childKeyScan, err := h.client.WalletGetBalance(&nockchain.GetBalanceRequest{ ownerHash := HashLock(ownerLock)
Selector: &nockchain.GetBalanceRequest_Address{ var scanReq *nockchain.GetBalanceRequest
Address: address, switch req.Version {
}, case 0:
}) scanReq = &nockchain.GetBalanceRequest{
Selector: &nockchain.GetBalanceRequest_Address{
Address: base58.Encode(childKey.PublicKey),
},
}
case 1:
firstName := crypto.Tip5RehashTenCell(crypto.Tip5Zero, ownerHash)
scanReq = &nockchain.GetBalanceRequest{
Selector: &nockchain.GetBalanceRequest_FirstName{
FirstName: crypto.Tip5HashToBase58(firstName),
},
}
default:
return nil, fmt.Errorf("unsuport version")
}
childKeyScan, err := h.client.WalletGetBalance(scanReq)
if err != nil { if err != nil {
continue continue
} }