diff --git a/src/client/rpc_api.rs b/src/client/rpc_api.rs index dc1b0c2..9d82fa2 100644 --- a/src/client/rpc_api.rs +++ b/src/client/rpc_api.rs @@ -45,7 +45,28 @@ impl RpcApi for Client { ) -> bitcoincore_rpc::Result { Ok(self.ledger.get_transaction(*txid)) } - + fn get_raw_transaction_info( + &self, + txid: &bitcoin::Txid, + _block_hash: Option<&bitcoin::BlockHash>, + ) -> bitcoincore_rpc::Result { + Ok(GetRawTransactionResult { + in_active_chain: None, + hex: vec![], + txid: *txid, + hash: Wtxid::hash(&[0]), + size: 0, + vsize: 0, + version: 0, + locktime: 0, + vin: vec![], + vout: vec![], + blockhash: None, + confirmations: Some(10), + time: None, + blocktime: None, + }) + } fn send_raw_transaction( &self, tx: R, @@ -57,34 +78,6 @@ impl RpcApi for Client { Ok(tx.compute_txid()) } - fn send_to_address( - &self, - address: &Address, - amount: Amount, - _comment: Option<&str>, - _comment_to: Option<&str>, - _subtract_fee: Option, - _replaceable: Option, - _confirmation_target: Option, - _estimate_mode: Option, - ) -> bitcoincore_rpc::Result { - let txin = TxIn::default(); - let txout = TxOut { - value: amount, - script_pubkey: address.script_pubkey(), - }; - let tx = bitcoin::Transaction { - version: bitcoin::transaction::Version(2), - lock_time: absolute::LockTime::from_consensus(0), - input: vec![txin], - output: vec![txout], - }; - - let txid = self.send_raw_transaction(&tx)?; - - Ok(txid) - } - fn get_transaction( &self, txid: &bitcoin::Txid, @@ -122,6 +115,36 @@ impl RpcApi for Client { Ok(res) } + fn send_to_address( + &self, + address: &Address, + amount: Amount, + _comment: Option<&str>, + _comment_to: Option<&str>, + _subtract_fee: Option, + _replaceable: Option, + _confirmation_target: Option, + _estimate_mode: Option, + ) -> bitcoincore_rpc::Result { + let txin = TxIn::default(); + let txout = TxOut { + value: amount, + script_pubkey: address.script_pubkey(), + }; + let tx = bitcoin::Transaction { + version: bitcoin::transaction::Version(2), + lock_time: absolute::LockTime::from_consensus(0), + input: vec![txin], + output: vec![txout], + }; + + let txid = self.send_raw_transaction(&tx)?; + + self.ledger.add_transaction_unconditionally(tx); + + Ok(txid) + } + fn get_new_address( &self, _label: Option<&str>, @@ -141,29 +164,6 @@ impl RpcApi for Client { Ok(address) } - fn get_raw_transaction_info( - &self, - txid: &bitcoin::Txid, - _block_hash: Option<&bitcoin::BlockHash>, - ) -> bitcoincore_rpc::Result { - Ok(GetRawTransactionResult { - in_active_chain: None, - hex: vec![], - txid: *txid, - hash: Wtxid::hash(&[0]), - size: 0, - vsize: 0, - version: 0, - locktime: 0, - vin: vec![], - vout: vec![], - blockhash: None, - confirmations: Some(10), - time: None, - blocktime: None, - }) - } - /// Generates `block_num` amount of block rewards to user. fn generate_to_address( &self,