diff --git a/rpc/utxo.go b/rpc/utxo.go index 625a248bd..d668a1f21 100644 --- a/rpc/utxo.go +++ b/rpc/utxo.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/MixinNetwork/mixin/common" + "github.com/MixinNetwork/mixin/crypto" ) func GetUTXO(rpc, hash string, index uint64) (*common.UTXOWithLock, error) { @@ -11,10 +12,28 @@ func GetUTXO(rpc, hash string, index uint64) (*common.UTXOWithLock, error) { if err != nil { return nil, err } - var out common.UTXOWithLock + var out struct { + Type uint8 `json:"type"` + Hash crypto.Hash `json:"hash"` + Index uint `json:"index"` + Amount common.Integer `json:"amount"` + Keys []*crypto.Key `json:"keys"` + Script common.Script `json:"script"` + Mask *crypto.Key `json:"mask"` + LockHash crypto.Hash `json:"lock"` + } err = json.Unmarshal(data, &out) if err != nil { panic(string(data)) } - return &out, err + + utxo := &common.UTXOWithLock{LockHash: out.LockHash} + utxo.Type = out.Type + utxo.Hash = out.Hash + utxo.Index = out.Index + utxo.Amount = out.Amount + utxo.Keys = out.Keys + utxo.Script = out.Script + utxo.Mask = *out.Mask + return utxo, nil }