コード例 #1
0
ファイル: trezor.py プロジェクト: faircoin/electrumfair
 def electrum_tx_to_txtype(self, tx, xpub_path):
     t = TransactionType()
     if tx is None:
         # probably for segwit input and we don't need this prev txn
         return t
     d = deserialize(tx.raw)
     t.version = d['version']
     t.lock_time = d['lockTime']
     t.inputs = self.tx_inputs(tx, xpub_path)
     t.bin_outputs = [
         TxOutputBinType(amount=vout['value'], script_pubkey=bfh(vout['scriptPubKey']))
         for vout in d['outputs']
     ]
     return t
コード例 #2
0
ファイル: trezor.py プロジェクト: wagnehc/electrumsv
    def sign_transaction(self, keystore: TrezorKeyStore, tx: Transaction,
                         xpub_path: Dict[str, str],
                         tx_context: TransactionContext) -> None:
        prev_txtypes: Dict[bytes, TransactionType] = {}
        for prev_tx_hash, prev_tx in tx_context.prev_txs.items():
            txtype = TransactionType()
            txtype.version = prev_tx.version
            txtype.lock_time = prev_tx.locktime
            txtype.inputs = self.tx_inputs(prev_tx, is_prev_tx=True)
            txtype.bin_outputs = [
                TxOutputBinType(amount=tx_output.value,
                                script_pubkey=bytes(tx_output.script_pubkey))
                for tx_output in prev_tx.outputs
            ]
            # Trezor tx hashes are same byte order as the reversed hex tx id.
            prev_trezor_tx_hash = bytes(reversed(prev_tx_hash))
            prev_txtypes[prev_trezor_tx_hash] = txtype

        client = self.get_client(keystore)
        inputs = self.tx_inputs(tx, xpub_path)
        outputs = self.tx_outputs(keystore, keystore.get_derivation(), tx)
        details = SignTx(lock_time=tx.locktime)
        signatures, _ = client.sign_tx(self.get_coin_name(),
                                       inputs,
                                       outputs,
                                       details=details,
                                       prev_txes=prev_txtypes)
        tx.update_signatures(signatures)
コード例 #3
0
 def electrum_tx_to_txtype(self, tx, xpub_path):
     t = TransactionType()
     d = deserialize(tx.raw)
     t.version = d['version']
     t.lock_time = d['lockTime']
     t.inputs = self.tx_inputs(tx, xpub_path)
     t.bin_outputs = [
         TxOutputBinType(amount=vout['value'], script_pubkey=bfh(vout['scriptPubKey']))
         for vout in d['outputs']
     ]
     return t
コード例 #4
0
 def electrum_tx_to_txtype(self, tx: Optional[Transaction]):
     t = TransactionType()
     if tx is None:
         # probably for segwit input and we don't need this prev txn
         return t
     tx.deserialize()
     t.version = tx.version
     t.timestamp = tx.time
     t.lock_time = tx.locktime
     t.inputs = self.tx_inputs(tx)
     t.bin_outputs = [
         TxOutputBinType(amount=o.value, script_pubkey=o.scriptpubkey)
         for o in tx.outputs()
     ]
     return t
コード例 #5
0
ファイル: trezor.py プロジェクト: swat69/electrum_dev
 def electrum_tx_to_txtype(self, tx, xpub_path):
     t = TransactionType()
     if tx is None:
         # probably for segwit input and we don't need this prev txn
         return t
     d = deserialize(tx.raw)
     t.version = d['version']
     t.timestamp = d['time']
     t.lock_time = d['lockTime']
     t.inputs = self.tx_inputs(tx, xpub_path)
     t.bin_outputs = [
         TxOutputBinType(amount=vout['value'],
                         script_pubkey=bfh(vout['scriptPubKey']))
         for vout in d['outputs']
     ]
     return t
コード例 #6
0
ファイル: trezor.py プロジェクト: firoorg/electrum-firo
 def electrum_tx_to_txtype(self, tx: Optional[Transaction]):
     t = TransactionType()
     if tx is None:
         # probably for segwit input and we don't need this prev txn
         return t
     tx.deserialize()
     t.version = tx.version
     t.lock_time = tx.locktime
     t.inputs = self.tx_inputs(tx)
     t.bin_outputs = [
         TxOutputBinType(amount=o.value, script_pubkey=o.scriptpubkey)
         for o in tx.outputs()
     ]
     if t.version > 2:
         tx_type = tx.tx_type
         if tx_type:
             t.extra_data = to_varbytes(serialize_extra_payload(tx))
             t.version |= tx_type << 16
     return t
コード例 #7
0
ファイル: trezor.py プロジェクト: justanwar/electrum-xzc
 def electrum_tx_to_txtype(self, tx, xpub_path):
     t = TransactionType()
     if tx is None:
         # probably for segwit input and we don't need this prev txn
         return t
     d = deserialize(tx.raw)
     t.version = d['version']
     t.lock_time = d['lockTime']
     t.inputs = self.tx_inputs(tx, xpub_path)
     t.bin_outputs = [
         TxOutputBinType(amount=vout['value'],
                         script_pubkey=bfh(vout['scriptPubKey']))
         for vout in d['outputs']
     ]
     if t.version > 2:
         tx_type = d['tx_type']
         if tx_type:
             t.extra_data = to_varbytes(serialize_extra_payload(tx))
             t.version |= tx_type << 16
     return t
コード例 #8
0
    def electrum_tx_to_txtype(self, tx: Optional[Transaction]):
        t = TransactionType()
        if tx is None:
            # probably for segwit input and we don't need this prev txn
            return t
        tx.deserialize()
        t.version = tx.version
        t.lock_time = tx.locktime
        t.inputs = self.tx_inputs(tx)
        for o in tx.outputs():
            if o.asset:
                raise UserFacingException(_("Trezor does not currently support asset transactions"))

        t.bin_outputs = [
            TxOutputBinType(amount=o.value.value, script_pubkey=o.scriptpubkey)
            for o in tx.outputs()
        ]
        return t