Пример #1
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)
     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
Пример #2
0
 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