MCPcopy Create free account
hub / github.com/ElementsProject/elements / get_utxo

Method get_utxo

test/functional/test_framework/wallet.py:140–155  ·  view source on GitHub ↗

Returns a utxo and marks it as spent (pops it from the internal list) Args: txid: get the first utxo we find from a specific transaction

(self, *, txid: Optional[str]='', mark_as_spent=True)

Source from the content-addressed store, hash-verified

138 return self._address
139
140 def get_utxo(self, *, txid: Optional[str]='', mark_as_spent=True):
141 """
142 Returns a utxo and marks it as spent (pops it from the internal list)
143
144 Args:
145 txid: get the first utxo we find from a specific transaction
146 """
147 index = -1 # by default the last utxo
148 self._utxos = sorted(self._utxos, key=lambda k: (k['value'], -k['height'])) # Put the largest utxo last
149 if txid:
150 utxo = next(filter(lambda utxo: txid == utxo['txid'], self._utxos))
151 index = self._utxos.index(utxo)
152 if mark_as_spent:
153 return self._utxos.pop(index)
154 else:
155 return self._utxos[index]
156
157 def send_self_transfer(self, **kwargs):
158 """Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""

Callers 14

run_testMethod · 0.95
run_testMethod · 0.95
run_testMethod · 0.95
run_testMethod · 0.95
run_testMethod · 0.95
create_self_transferMethod · 0.95
run_testMethod · 0.45
create_txMethod · 0.45
run_testMethod · 0.45
send_generic_input_txMethod · 0.45

Calls 1

indexMethod · 0.45

Tested by 3

test_rpcMethod · 0.36