File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ impl Ledger {
57
57
58
58
self . add_mempool_transaction ( txid) ?;
59
59
60
+ self . handle_transaction_utxos ( & transaction) ?;
61
+
60
62
Ok ( txid)
61
63
}
62
64
@@ -267,6 +269,20 @@ impl Ledger {
267
269
amount
268
270
}
269
271
272
+ /// Removes inputs from UTXOs and adds outputs to UTXOs.
273
+ pub fn handle_transaction_utxos ( & self , transaction : & Transaction ) -> Result < ( ) , LedgerError > {
274
+ for input in & transaction. input {
275
+ self . remove_utxo ( input. previous_output ) ?;
276
+ }
277
+
278
+ let txid = transaction. compute_txid ( ) ;
279
+ for vout in 0 ..( transaction. output . len ( ) as u32 ) {
280
+ self . add_utxo ( OutPoint { txid, vout } ) ?;
281
+ }
282
+
283
+ Ok ( ( ) )
284
+ }
285
+
270
286
/// Creates a `TxIn` with some defaults.
271
287
pub fn create_txin ( & self , txid : Txid , vout : u32 ) -> TxIn {
272
288
TxIn {
You can’t perform that action at this time.
0 commit comments