@@ -506,32 +506,50 @@ func PrepareOutputAssets(ctx context.Context, vPkt *tappsbt.VPacket) error {
506506 )
507507
508508 if isFullValueInteractiveSend {
509- if len (inputs ) != 1 {
510- return fmt .Errorf ("full value interactive send " +
511- "must have exactly one input" )
509+ // Sum the total amount of the input assets.
510+ inputsAmountSum := uint64 (0 )
511+ for idx := range inputs {
512+ input := inputs [idx ]
513+
514+ // At the moment, we need to ensure that all inputs have
515+ // the same asset ID. We've already checked that above,
516+ // but we will do it again here for clarity.
517+ if inputs [idx ].Asset ().ID () != assetID {
518+ return fmt .Errorf ("multiple input assets " +
519+ "must have the same asset ID" )
520+ }
521+
522+ inputsAmountSum += input .Asset ().Amount
512523 }
513524
514- // TODO(ffranr): Add support for interactive full value multiple
515- // input spend.
516- input := inputs [ 0 ]
517- vOut := outputs [ recipientIndex ]
525+ // At this point we know that each input has the same asset ID
526+ // we therefore arbitrarily select the first input as our
527+ // template output asset.
528+ firstInput := inputs [ 0 ]
518529
519530 // We'll now create a new copy of the old asset, swapping out
520531 // the script key. We blank out the tweaked key information as
521532 // this is now an external asset.
522- vOut .Asset = input .Asset ().Copy ()
533+ vOut := outputs [recipientIndex ]
534+ vOut .Asset = firstInput .Asset ().Copy ()
535+ vOut .Asset .Amount = inputsAmountSum
523536 vOut .Asset .ScriptKey = vOut .ScriptKey
524537
525- // Record the PrevID of the input asset in a Witness for the new
526- // asset. This Witness still needs a valid signature for the new
527- // asset to be valid.
528- vOut .Asset .PrevWitnesses = []asset.Witness {
529- {
538+ // Gather previous witnesses from the input assets.
539+ prevWitnesses := make ([]asset.Witness , len (inputs ))
540+ for idx := range inputs {
541+ input := inputs [idx ]
542+
543+ // Record the PrevID of the input asset in a Witness for
544+ // the new asset. This Witness still needs a valid
545+ // signature for the new asset to be valid.
546+ prevWitnesses [idx ] = asset.Witness {
530547 PrevID : & input .PrevID ,
531548 TxWitness : nil ,
532549 SplitCommitment : nil ,
533- },
550+ }
534551 }
552+ vOut .Asset .PrevWitnesses = prevWitnesses
535553
536554 // Adjust the version for the requested send type.
537555 vOut .Asset .Version = vOut .AssetVersion
0 commit comments