Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
    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)
Beispiel #4
0
 def sign_tx(self, rawtx, wifs):
     """Sign <rawtx> with  given <wifs> as json data.
     <wifs>: '["privatekey_in_wif_format", ...]'
     """
     tx = deserialize.tx(rawtx)
     keys = deserialize.keys(self.testnet, wifs)
     tx = control.sign_tx(self.service, self.testnet, tx, keys)
     return serialize.tx(tx)
Beispiel #5
0
 def sign_tx(self, rawtx, wifs):
     """Sign <rawtx> with  given <wifs> as json data.
     <wifs>: '["privatekey_in_wif_format", ...]'
     """
     tx = deserialize.tx(rawtx)
     keys = deserialize.keys(self.testnet, wifs)
     tx = control.sign_tx(self.service, self.testnet, tx, keys)
     return serialize.tx(tx)
Beispiel #6
0
 def add_broadcast_message(self, rawtx, message, sender_wif,
                           dust_limit=common.DUST_LIMIT):
     """TODO add docstring"""
     tx = deserialize.tx(rawtx)
     message = deserialize.unicode_str(message)
     sender_key = deserialize.key(self.testnet, sender_wif)
     tx = control.add_broadcast_message(self.testnet, tx, message,
                                        sender_key, dust_limit=dust_limit)
     return serialize.tx(tx)
Beispiel #7
0
 def add_broadcast_message(self, rawtx, message, sender_wif,
                           dust_limit=common.DUST_LIMIT):
     """TODO add docstring"""
     tx = deserialize.tx(rawtx)
     message = deserialize.unicode_str(message)
     sender_key = deserialize.key(self.testnet, sender_wif)
     tx = control.add_broadcast_message(self.testnet, tx, message,
                                        sender_key, dust_limit=dust_limit)
     return serialize.tx(tx)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
    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)
Beispiel #11
0
 def add_data_blob(self, rawtx, hexdata, dust_limit=common.DUST_LIMIT):
     """TODO add docstring"""
     tx = deserialize.tx(rawtx)
     data = deserialize.binary(hexdata)
     tx = control.add_data_blob(tx, data, dust_limit=dust_limit)
     return serialize.tx(tx)
Beispiel #12
0
 def add_nulldata(self, rawtx, hexdata):
     """Writes <hexdata> as new nulldata output to <rawtx>."""
     tx = deserialize.unsignedtx(rawtx)
     nulldata_txout = deserialize.nulldata_txout(hexdata)
     tx = control.add_nulldata_output(tx, nulldata_txout)
     return serialize.tx(tx)
Beispiel #13
0
 def retrieve_tx(self, txid):
     """Returns rawtx for <txid>."""
     txid = deserialize.txid(txid)
     tx = self.service.get_tx(txid)
     return serialize.tx(tx)
Beispiel #14
0
 def add_data_blob(self, rawtx, hexdata, dust_limit=common.DUST_LIMIT):
     """TODO add docstring"""
     tx = deserialize.tx(rawtx)
     data = deserialize.binary(hexdata)
     tx = control.add_data_blob(tx, data, dust_limit=dust_limit)
     return serialize.tx(tx)
Beispiel #15
0
 def add_nulldata(self, rawtx, hexdata):
     """Writes <hexdata> as new nulldata output to <rawtx>."""
     tx = deserialize.unsignedtx(rawtx)
     nulldata_txout = deserialize.nulldata_txout(hexdata)
     tx = control.add_nulldata_output(tx, nulldata_txout)
     return serialize.tx(tx)
Beispiel #16
0
 def retrieve_tx(self, txid):
     """Returns rawtx for <txid>."""
     txid = deserialize.txid(txid)
     tx = self.service.get_tx(txid)
     return serialize.tx(tx)