fix: scan v1
This commit is contained in:
parent
3ab2b57835
commit
a9fe28d5ea
@ -744,23 +744,38 @@ func (h *GprcHandler) Scan(ctx context.Context, req *nockchain.ScanRequest) (*no
|
||||
continue
|
||||
}
|
||||
|
||||
address := ""
|
||||
if req.Version == 0 {
|
||||
address = base58.Encode(childKey.PublicKey)
|
||||
} else {
|
||||
pkPoint, err := crypto.CheetaPointFromBytes(childKey.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkHash := HashPubkey(pkPoint)
|
||||
address = crypto.Tip5HashToBase58(pkHash)
|
||||
ownerLock := &nockchain.NockchainLock{
|
||||
KeysRequired: 1,
|
||||
Pubkeys: []string{crypto.Tip5HashToBase58(pkHash)},
|
||||
}
|
||||
|
||||
childKeyScan, err := h.client.WalletGetBalance(&nockchain.GetBalanceRequest{
|
||||
ownerHash := HashLock(ownerLock)
|
||||
var scanReq *nockchain.GetBalanceRequest
|
||||
switch req.Version {
|
||||
case 0:
|
||||
scanReq = &nockchain.GetBalanceRequest{
|
||||
Selector: &nockchain.GetBalanceRequest_Address{
|
||||
Address: 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 {
|
||||
continue
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user