@@ -467,9 +467,14 @@ pub trait CoinSelectionSource {
467
467
& self , claim_id : ClaimId , must_spend : & [ Input ] , must_pay_to : & [ TxOut ] ,
468
468
target_feerate_sat_per_1000_weight : u32 ,
469
469
) -> Result < CoinSelection , ( ) > ;
470
+ #[ cfg( not( c_bindings) ) ]
470
471
/// Signs and provides the full witness for all inputs within the transaction known to the
471
472
/// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]).
472
473
fn sign_tx ( & self , tx : & mut Transaction ) -> Result < ( ) , ( ) > ;
474
+ #[ cfg( c_bindings) ]
475
+ /// Signs and provides the full witness for all inputs within the transaction known to the
476
+ /// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]).
477
+ fn sign_tx ( & self , tx : Transaction ) -> Result < Transaction , ( ) > ;
473
478
}
474
479
475
480
/// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
@@ -480,10 +485,16 @@ pub trait WalletSource {
480
485
/// Returns a script to use for change above dust resulting from a successful coin selection
481
486
/// attempt.
482
487
fn get_change_script ( & self ) -> Result < Script , ( ) > ;
488
+ #[ cfg( not( c_bindings) ) ]
483
489
/// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
484
490
/// the transaction known to the wallet (i.e., any provided via
485
491
/// [`WalletSource::list_confirmed_utxos`]).
486
492
fn sign_tx ( & self , tx : & mut Transaction ) -> Result < ( ) , ( ) > ;
493
+ #[ cfg( c_bindings) ]
494
+ /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
495
+ /// the transaction known to the wallet (i.e., any provided via
496
+ /// [`WalletSource::list_confirmed_utxos`]).
497
+ fn sign_tx ( & self , tx : Transaction ) -> Result < Transaction , ( ) > ;
487
498
}
488
499
489
500
/// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
@@ -629,9 +640,15 @@ where
629
640
. or_else ( |_| do_coin_selection ( true , true ) )
630
641
}
631
642
643
+ #[ cfg( not( c_bindings) ) ]
632
644
fn sign_tx ( & self , tx : & mut Transaction ) -> Result < ( ) , ( ) > {
633
645
self . source . sign_tx ( tx)
634
646
}
647
+
648
+ #[ cfg( c_bindings) ]
649
+ fn sign_tx ( & self , tx : Transaction ) -> Result < Transaction , ( ) > {
650
+ self . source . sign_tx ( tx)
651
+ }
635
652
}
636
653
637
654
/// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a
@@ -748,7 +765,13 @@ where
748
765
let unsigned_tx_weight = anchor_tx. weight ( ) as u64 - ( anchor_tx. input . len ( ) as u64 * EMPTY_SCRIPT_SIG_WEIGHT ) ;
749
766
750
767
log_debug ! ( self . logger, "Signing anchor transaction {}" , anchor_txid) ;
751
- self . utxo_source . sign_tx ( & mut anchor_tx) ?;
768
+ #[ cfg( not( c_bindings) ) ] {
769
+ self . utxo_source . sign_tx ( & mut anchor_tx) ?;
770
+ }
771
+ #[ cfg( c_bindings) ] {
772
+ anchor_tx = self . utxo_source . sign_tx ( anchor_tx) ?;
773
+ }
774
+
752
775
let signer = anchor_descriptor. derive_channel_signer ( & self . signer_provider ) ;
753
776
let anchor_sig = signer. sign_holder_anchor_input ( & anchor_tx, 0 , & self . secp ) ?;
754
777
anchor_tx. input [ 0 ] . witness = anchor_descriptor. tx_input_witness ( & anchor_sig) ;
@@ -812,7 +835,13 @@ where
812
835
let unsigned_tx_weight = htlc_tx. weight ( ) as u64 - ( htlc_tx. input . len ( ) as u64 * EMPTY_SCRIPT_SIG_WEIGHT ) ;
813
836
814
837
log_debug ! ( self . logger, "Signing HTLC transaction {}" , htlc_tx. txid( ) ) ;
815
- self . utxo_source . sign_tx ( & mut htlc_tx) ?;
838
+ #[ cfg( not( c_bindings) ) ] {
839
+ self . utxo_source . sign_tx ( & mut htlc_tx) ?;
840
+ }
841
+ #[ cfg( c_bindings) ] {
842
+ htlc_tx = self . utxo_source . sign_tx ( htlc_tx) ?;
843
+ }
844
+
816
845
let mut signers = BTreeMap :: new ( ) ;
817
846
for ( idx, htlc_descriptor) in htlc_descriptors. iter ( ) . enumerate ( ) {
818
847
let signer = signers. entry ( htlc_descriptor. channel_derivation_parameters . keys_id )
0 commit comments