We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 397ac4e commit 772d76aCopy full SHA for 772d76a
src/ledger/mod.rs
@@ -22,8 +22,12 @@ impl Ledger {
22
}
23
24
/// Adds a new UTXO to user's UTXO's.
25
- pub fn add_utxo(&mut self, utxo: TxOut) {
26
- self.utxos.push(utxo);
+ pub fn add_utxo(&self, utxo: TxOut) -> Self {
+ let mut ledger = self.clone().to_owned();
27
+
28
+ ledger.utxos.push(utxo);
29
30
+ ledger
31
32
33
/// Adds a new address for user.
@@ -80,7 +84,7 @@ mod tests {
80
84
value: Amount::from_sat(0x45),
81
85
script_pubkey: ledger.addresses[0].script_pubkey(),
82
86
};
83
- ledger.add_utxo(utxo);
87
+ ledger = ledger.add_utxo(utxo);
88
89
assert_eq!(ledger.utxos.len(), 1);
90
assert_eq!(ledger.utxos[0].value, Amount::from_sat(0x45));
0 commit comments