62
62
import io .muun .common .api .IntegrityStatus ;
63
63
import io .muun .common .api .KeySet ;
64
64
import io .muun .common .api .LinkActionJson ;
65
+ import io .muun .common .api .OperationJson ;
65
66
import io .muun .common .api .PasswordSetupJson ;
66
67
import io .muun .common .api .PhoneConfirmation ;
67
68
import io .muun .common .api .PlayIntegrityTokenJson ;
68
69
import io .muun .common .api .PreimageJson ;
69
70
import io .muun .common .api .PublicKeySetJson ;
71
+ import io .muun .common .api .PushTransactionsJson ;
70
72
import io .muun .common .api .RawTransaction ;
71
73
import io .muun .common .api .SetupChallengeResponse ;
72
74
import io .muun .common .api .UpdateOperationMetadataJson ;
100
102
import rx .Observable ;
101
103
import rx .Single ;
102
104
105
+ import java .util .ArrayList ;
103
106
import java .util .List ;
104
107
import javax .annotation .Nullable ;
105
108
import javax .inject .Inject ;
@@ -603,10 +606,14 @@ public Observable<IntegrityStatus> checkIntegrity(IntegrityCheck integrityCheck)
603
606
public Observable <OperationCreated > newOperation (
604
607
final OperationWithMetadata operation ,
605
608
final List <String > outpoints ,
606
- final MusigNonces musigNonces
609
+ final MusigNonces musigNonces ,
610
+ final List <MusigNonces > alternativeTxNonces
607
611
) {
612
+ final OperationJson operationJson =
613
+ apiMapper .mapOperation (operation , outpoints , musigNonces , alternativeTxNonces );
614
+
608
615
return getService ()
609
- .newOperation (apiMapper . mapOperation ( operation , outpoints , musigNonces ) )
616
+ .newOperation (operationJson )
610
617
.map (modelMapper ::mapOperationCreated );
611
618
}
612
619
@@ -623,29 +630,44 @@ public Completable updateOperationMetadata(OperationWithMetadata operation) {
623
630
624
631
/**
625
632
* Pushes a raw transaction to Houston.
626
- *
627
- * @param txHex The bitcoinj's transaction.
628
- * @param operationHid The houston operation id.
629
633
*/
630
- public Observable <TransactionPushed > pushTransaction (
634
+ public Observable <TransactionPushed > pushTransactions (
631
635
@ Nullable String txHex ,
636
+ @ Nullable List <String > alternativeTransactionsHex ,
632
637
long operationHid
633
638
) {
639
+ final RawTransaction rawTransaction ;
640
+ final ArrayList <RawTransaction > alternativeTransactions = new ArrayList <RawTransaction >();
641
+
634
642
if (txHex != null ) {
635
- return getService ()
636
- .pushTransaction (new RawTransaction (txHex ), operationHid )
637
- // This can happen if we determine the payment can't actually be made. If so, we
638
- // fail fast to avoid broadcasting a transaction saving the user on miner fees.
639
- .compose (ObservableFn .replaceHttpException (
640
- ErrorCode .SWAP_FAILED ,
641
- SwapFailedException ::new
642
- ))
643
- .map (modelMapper ::mapTransactionPushed );
643
+ Preconditions .checkArgument (alternativeTransactionsHex != null );
644
+
645
+ rawTransaction = new RawTransaction (txHex );
646
+
647
+ for (var transactionHex : alternativeTransactionsHex ) {
648
+ alternativeTransactions .add (new RawTransaction (transactionHex ));
649
+ }
650
+
644
651
} else {
645
- return getService ()
646
- . pushTransaction ( operationHid ) // empty body when txHex is not given
647
- . map ( modelMapper :: mapTransactionPushed ) ;
652
+ Preconditions . checkArgument ( alternativeTransactionsHex == null );
653
+
654
+ rawTransaction = null ;
648
655
}
656
+
657
+ final var json = new PushTransactionsJson (
658
+ rawTransaction ,
659
+ alternativeTransactions
660
+ );
661
+
662
+ return getService ()
663
+ .pushTransactions (json , operationHid )
664
+ // This can happen if we determine the payment can't actually be made. If so, we
665
+ // fail fast to avoid broadcasting a transaction saving the user on miner fees.
666
+ .compose (ObservableFn .replaceHttpException (
667
+ ErrorCode .SWAP_FAILED ,
668
+ SwapFailedException ::new
669
+ ))
670
+ .map (modelMapper ::mapTransactionPushed );
649
671
}
650
672
651
673
/**
0 commit comments