@@ -1097,17 +1097,13 @@ func (r *rpcServer) ListAssets(ctx context.Context,
1097
1097
}
1098
1098
1099
1099
if req .AnchorOutpoint != nil {
1100
- txid , err := chainhash . NewHash (req .AnchorOutpoint . Txid )
1100
+ op , err := rpcutils . UnmarshalOutPoint (req .AnchorOutpoint )
1101
1101
if err != nil {
1102
- return nil , fmt .Errorf ("error parsing outpoint: %w" ,
1102
+ return nil , fmt .Errorf ("unmarshalling outpoint: %w" ,
1103
1103
err )
1104
1104
}
1105
- outPoint := & wire.OutPoint {
1106
- Hash : * txid ,
1107
- Index : req .AnchorOutpoint .OutputIndex ,
1108
- }
1109
1105
1110
- filters .AnchorPoint = outPoint
1106
+ filters .AnchorPoint = & op
1111
1107
}
1112
1108
1113
1109
scriptKeyType , includeSpent , err := rpcutils .ParseScriptKeyTypeQuery (
@@ -2054,15 +2050,13 @@ func (r *rpcServer) ExportProof(ctx context.Context,
2054
2050
// error will be returned and the outpoint needs to be specified to
2055
2051
// disambiguate.
2056
2052
if req .Outpoint != nil {
2057
- txid , err := chainhash . NewHash (req .Outpoint . Txid )
2053
+ op , err := rpcutils . UnmarshalOutPoint (req .Outpoint )
2058
2054
if err != nil {
2059
- return nil , fmt .Errorf ("error parsing outpoint: %w" ,
2055
+ return nil , fmt .Errorf ("unmarshalling outpoint: %w" ,
2060
2056
err )
2061
2057
}
2062
- outPoint = & wire.OutPoint {
2063
- Hash : * txid ,
2064
- Index : req .Outpoint .OutputIndex ,
2065
- }
2058
+
2059
+ outPoint = & op
2066
2060
}
2067
2061
2068
2062
proofBlob , err := r .cfg .ProofArchive .FetchProof (ctx , proof.Locator {
@@ -2255,14 +2249,19 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
2255
2249
)
2256
2250
for i , input := range raw .Inputs {
2257
2251
if input .Outpoint == nil {
2252
+ // Return an error message which specifically
2253
+ // refers to the index which has a corresponding
2254
+ // nil outpoint.
2258
2255
return nil , fmt .Errorf ("input at index %d has " +
2259
2256
"a nil Outpoint" , i )
2260
2257
}
2261
2258
2262
- hash , err := chainhash .NewHash (input .Outpoint .Txid )
2259
+ outPoint , err := rpcutils .UnmarshalOutPoint (
2260
+ input .Outpoint ,
2261
+ )
2263
2262
if err != nil {
2264
- return nil , fmt .Errorf ("input at index %d has " +
2265
- "invalid Txid : %w" , i , err )
2263
+ return nil , fmt .Errorf ("unmarshalling " +
2264
+ "outpoint : %w" , err )
2266
2265
}
2267
2266
2268
2267
scriptKey , err := parseUserKey (input .ScriptKey )
@@ -2278,12 +2277,8 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
2278
2277
}
2279
2278
2280
2279
// Decode the input into an asset.PrevID.
2281
- outpoint := wire.OutPoint {
2282
- Hash : * hash ,
2283
- Index : input .Outpoint .OutputIndex ,
2284
- }
2285
2280
prevID := asset.PrevID {
2286
- OutPoint : outpoint ,
2281
+ OutPoint : outPoint ,
2287
2282
ID : asset .ID (input .Id ),
2288
2283
ScriptKey : asset .ToSerialized (
2289
2284
scriptKey ,
@@ -2970,15 +2965,13 @@ func (r *rpcServer) PublishAndLogTransfer(ctx context.Context,
2970
2965
FinalTx : finalTx ,
2971
2966
}
2972
2967
for idx , lndOutpoint := range req .LndLockedUtxos {
2973
- hash , err := chainhash . NewHash (lndOutpoint . Txid )
2968
+ op , err := rpcutils . UnmarshalOutPoint (lndOutpoint )
2974
2969
if err != nil {
2975
- return nil , fmt .Errorf ("error parsing txid: %w" , err )
2970
+ return nil , fmt .Errorf ("unmarshalling outpoint: %w" ,
2971
+ err )
2976
2972
}
2977
2973
2978
- anchorTx .FundedPsbt .LockedUTXOs [idx ] = wire.OutPoint {
2979
- Hash : * hash ,
2980
- Index : lndOutpoint .OutputIndex ,
2981
- }
2974
+ anchorTx .FundedPsbt .LockedUTXOs [idx ] = op
2982
2975
}
2983
2976
2984
2977
// We now have everything to ship the pre-anchored parcel using the
@@ -6289,15 +6282,13 @@ func (r *rpcServer) ProveAssetOwnership(ctx context.Context,
6289
6282
// error will be returned and the outpoint needs to be specified to
6290
6283
// disambiguate.
6291
6284
if req .Outpoint != nil {
6292
- txid , err := chainhash . NewHash (req .Outpoint . Txid )
6285
+ op , err := rpcutils . UnmarshalOutPoint (req .Outpoint )
6293
6286
if err != nil {
6294
- return nil , fmt .Errorf ("error parsing outpoint: %w" ,
6287
+ return nil , fmt .Errorf ("unmarshalling outpoint: %w" ,
6295
6288
err )
6296
6289
}
6297
- outPoint = & wire.OutPoint {
6298
- Hash : * txid ,
6299
- Index : req .Outpoint .OutputIndex ,
6300
- }
6290
+
6291
+ outPoint = & op
6301
6292
}
6302
6293
6303
6294
proofBlob , err := r .cfg .ProofArchive .FetchProof (ctx , proof.Locator {
@@ -6584,18 +6575,9 @@ func (r *rpcServer) RemoveUTXOLease(ctx context.Context,
6584
6575
req * wrpc.RemoveUTXOLeaseRequest ) (* wrpc.RemoveUTXOLeaseResponse ,
6585
6576
error ) {
6586
6577
6587
- if req .Outpoint == nil {
6588
- return nil , fmt .Errorf ("outpoint must be specified" )
6589
- }
6590
-
6591
- hash , err := chainhash .NewHash (req .Outpoint .Txid )
6578
+ outPoint , err := rpcutils .UnmarshalOutPoint (req .Outpoint )
6592
6579
if err != nil {
6593
- return nil , fmt .Errorf ("error parsing txid: %w" , err )
6594
- }
6595
-
6596
- outPoint := wire.OutPoint {
6597
- Hash : * hash ,
6598
- Index : req .Outpoint .OutputIndex ,
6580
+ return nil , fmt .Errorf ("unmarshaling outpoint: %w" , err )
6599
6581
}
6600
6582
6601
6583
err = r .cfg .CoinSelect .ReleaseCoins (ctx , outPoint )
@@ -8753,15 +8735,13 @@ func (r *rpcServer) RegisterTransfer(ctx context.Context,
8753
8735
}
8754
8736
locator .ScriptKey = * scriptPubKey
8755
8737
8756
- hash , err := chainhash . NewHash (req .Outpoint . Txid )
8738
+ op , err := rpcutils . UnmarshalOutPoint (req .Outpoint )
8757
8739
if err != nil {
8758
- return nil , err
8759
- }
8760
- locator .OutPoint = & wire.OutPoint {
8761
- Hash : * hash ,
8762
- Index : req .Outpoint .OutputIndex ,
8740
+ return nil , fmt .Errorf ("unmarshalling outpoint: %w" , err )
8763
8741
}
8764
8742
8743
+ locator .OutPoint = & op
8744
+
8765
8745
// Before we query for the proof, we want to make sure the script key is
8766
8746
// already known to us. In an interactive transfer, we'd expect a script
8767
8747
// key to be derived on the recipient node, so it should already be
0 commit comments