@@ -3,7 +3,10 @@ use bitcoin::{
33 secp256k1:: { PublicKey as Secp256k1PublicKey , Secp256k1 , SecretKey } ,
44} ;
55use num_bigint:: BigInt ;
6- use primitives:: { Asset , BitcoinChain , GasPriceType , SignerInput , TransactionFee , TransactionInputType , TransactionLoadInput , TransactionLoadMetadata , UTXO } ;
6+ use primitives:: {
7+ Asset , BitcoinChain , GasPriceType , SignerInput , SwapProvider , TransactionFee , TransactionInputType , TransactionLoadInput , TransactionLoadMetadata , UTXO ,
8+ swap:: { SwapData , SwapProviderData , SwapQuote , SwapQuoteData } ,
9+ } ;
710
811use crate :: { signer:: address:: public_key_hash, testkit:: address_mock:: address_for_hash} ;
912
@@ -60,6 +63,47 @@ pub fn transfer_input(chain: BitcoinChain) -> SignerInput {
6063 )
6164}
6265
66+ pub fn funded_transfer_input ( chain : BitcoinChain ) -> SignerInput {
67+ let mut input = transfer_input ( chain) ;
68+ match & mut input. input . metadata {
69+ TransactionLoadMetadata :: Bitcoin { utxos } | TransactionLoadMetadata :: Zcash { utxos, .. } => {
70+ utxos[ 0 ] . value = "100000000" . to_string ( ) ;
71+ }
72+ _ => { }
73+ }
74+ input
75+ }
76+
77+ pub fn transfer_swap_input ( chain : BitcoinChain , memo : & str ) -> SignerInput {
78+ let mut input = funded_transfer_input ( chain) ;
79+ let sender_address = input. sender_address . clone ( ) ;
80+ let destination_address = input. destination_address . clone ( ) ;
81+ let value = input. value . clone ( ) ;
82+
83+ input. input . input_type = TransactionInputType :: Swap (
84+ Asset :: from_chain ( chain. get_chain ( ) ) ,
85+ Asset :: from_chain ( BitcoinChain :: Bitcoin . get_chain ( ) ) ,
86+ SwapData {
87+ quote : SwapQuote {
88+ from_address : sender_address,
89+ from_value : value. clone ( ) ,
90+ to_address : destination_address. clone ( ) ,
91+ to_value : value. clone ( ) ,
92+ provider_data : SwapProviderData {
93+ provider : SwapProvider :: Thorchain ,
94+ name : "THORChain" . to_string ( ) ,
95+ protocol_name : "thorchain" . to_string ( ) ,
96+ } ,
97+ slippage_bps : 50 ,
98+ eta_in_seconds : None ,
99+ use_max_amount : Some ( false ) ,
100+ } ,
101+ data : SwapQuoteData :: new_tranfer ( destination_address, value, Some ( memo. to_string ( ) ) ) ,
102+ } ,
103+ ) ;
104+ input
105+ }
106+
63107pub ( crate ) fn utxo_with ( transaction_id : & str , vout : i32 , value : & str , address : & str ) -> UTXO {
64108 UTXO {
65109 transaction_id : transaction_id. to_string ( ) ,
0 commit comments