def split_utxos(self, wif, limit, fee=10000, max_outputs=100): """Split utxos of <wif> unitil <limit> or <max_outputs> reached.""" key = deserialize.key(self.testnet, wif) limit = deserialize.positive_integer(limit) fee = deserialize.positive_integer(fee) max_outputs = deserialize.positive_integer(max_outputs) spendables = control.retrieve_utxos(self.service, [key.address()]) txids = control.split_utxos(self.service, self.testnet, key, spendables, limit, fee=fee, max_outputs=max_outputs, publish=(not self.dryrun)) return serialize.txids(txids)
def add_hash160data(self, rawtx, hexdata, dust_limit=common.DUST_LIMIT): """Writes <hexdata> as new Pay-to-PubkeyHash output to <rawtx>.""" tx = deserialize.unsignedtx(rawtx) dust_limit = deserialize.positive_integer(dust_limit) hash160data_txout = deserialize.hash160data_txout(hexdata, dust_limit) tx = control.add_hash160data_output(tx, hash160data_txout) return serialize.tx(tx)
def add_inputs(self, rawtx, wifs, change_address=None, fee=10000, dont_sign=False): """Add sufficient inputs from given <wifs> to cover <rawtx> outputs and <fee>. If no <change_address> is given, change will be sent to first wif. """ tx = deserialize.tx(rawtx) keys = deserialize.keys(self.testnet, wifs) fee = deserialize.positive_integer(fee) if change_address is not None: change_address = deserialize.address(self.testnet, change_address) tx = control.add_inputs(self.service, self.testnet, tx, keys, change_address=change_address, fee=fee) if not dont_sign: tx = control.sign_tx(self.service, self.testnet, tx, keys) return serialize.tx(tx)
def create_tx(self, txins=None, txouts=None, lock_time=0): """Create unsigned rawtx with given txins/txouts as json data. <txins>: '[{"txid" : hexdata, "index" : integer}, ...]' <txouts>: '[{"address" : hexdata, "value" : satoshis}, ...]' """ txins = [] if txins is None else txins txouts = [] if txouts is None else txouts lock_time = deserialize.positive_integer(lock_time) txins = deserialize.txins(txins) txouts = deserialize.txouts(self.testnet, txouts) tx = control.create_tx(self.service, self.testnet, txins, txouts, lock_time=lock_time) return serialize.tx(tx)
def get_hash160data(self, rawtx, output_index): """TODO doc string""" tx = deserialize.unsignedtx(rawtx) output_index = deserialize.positive_integer(output_index) data = control.get_hash160_data(tx, output_index) return serialize.data(data)