@@ -490,16 +490,58 @@ func FinalizePacket(t *testing.T, lnd *rpc.HarnessRPC,
490
490
return signedPacket
491
491
}
492
492
493
+ // PublishAndLogTransferOption defines a functional option for
494
+ // PublishAndLogTransfer.
495
+ type PublishAndLogTransferOption func (* publishAndLogTransferOptions )
496
+
497
+ // publishAndLogTransferOptions contains the options for PublishAndLogTransfer.
498
+ type publishAndLogTransferOptions struct {
499
+ // skipAnchorTxBroadcast indicates whether to skip the broadcast of
500
+ // the anchor transaction.
501
+ skipAnchorTxBroadcast bool
502
+
503
+ // label is the label to use for the transfer.
504
+ label string
505
+ }
506
+
507
+ // defaultPublishAndLogTransferOptions returns the default options for
508
+ // PublishAndLogTransfer.
509
+ func defaultPublishAndLogTransferOptions () * publishAndLogTransferOptions {
510
+ return & publishAndLogTransferOptions {}
511
+ }
512
+
513
+ // withSkipAnchorTxBroadcast is an option for PublishAndLogTransfer that
514
+ // indicates whether to skip the broadcast of the anchor transaction.
515
+ func withSkipAnchorTxBroadcast () PublishAndLogTransferOption {
516
+ return func (opts * publishAndLogTransferOptions ) {
517
+ opts .skipAnchorTxBroadcast = true
518
+ }
519
+ }
520
+
521
+ // withLabel is an option for PublishAndLogTransfer that sets the label for
522
+ // the transfer.
523
+ func withLabel (label string ) PublishAndLogTransferOption {
524
+ return func (opts * publishAndLogTransferOptions ) {
525
+ opts .label = label
526
+ }
527
+ }
528
+
493
529
// PublishAndLogTransfer is a helper function that invokes the
494
530
// PublishAndLogTransfer RPC endpoint on the specified tapd node. This endpoint
495
531
// performs a pre-anchored transfer.
496
532
func PublishAndLogTransfer (t * testing.T , tapd commands.RpcClientsBundle ,
497
533
btcPkt * psbt.Packet , activeAssets []* tappsbt.VPacket ,
498
534
passiveAssets []* tappsbt.VPacket ,
499
- commitResp * wrpc.CommitVirtualPsbtsResponse ) * taprpc.SendAssetResponse {
535
+ commitResp * wrpc.CommitVirtualPsbtsResponse ,
536
+ opts ... PublishAndLogTransferOption ) * taprpc.SendAssetResponse {
500
537
501
538
t .Helper ()
502
539
540
+ options := defaultPublishAndLogTransferOptions ()
541
+ for _ , opt := range opts {
542
+ opt (options )
543
+ }
544
+
503
545
ctxb := context .Background ()
504
546
ctxt , cancel := context .WithTimeout (ctxb , defaultWaitTimeout )
505
547
defer cancel ()
@@ -509,11 +551,13 @@ func PublishAndLogTransfer(t *testing.T, tapd commands.RpcClientsBundle,
509
551
require .NoError (t , err )
510
552
511
553
request := & wrpc.PublishAndLogRequest {
512
- AnchorPsbt : buf .Bytes (),
513
- VirtualPsbts : make ([][]byte , len (activeAssets )),
514
- PassiveAssetPsbts : make ([][]byte , len (passiveAssets )),
515
- ChangeOutputIndex : commitResp .ChangeOutputIndex ,
516
- LndLockedUtxos : commitResp .LndLockedUtxos ,
554
+ AnchorPsbt : buf .Bytes (),
555
+ VirtualPsbts : make ([][]byte , len (activeAssets )),
556
+ PassiveAssetPsbts : make ([][]byte , len (passiveAssets )),
557
+ ChangeOutputIndex : commitResp .ChangeOutputIndex ,
558
+ LndLockedUtxos : commitResp .LndLockedUtxos ,
559
+ SkipAnchorTxBroadcast : options .skipAnchorTxBroadcast ,
560
+ Label : options .label ,
517
561
}
518
562
519
563
for idx := range activeAssets {
0 commit comments