remove staled files
This commit is contained in:
parent
5946939c91
commit
a04483056f
|
@ -1,106 +0,0 @@
|
|||
#:import _ electrum_zcash_gui.kivy.i18n._
|
||||
#:import Decimal decimal.Decimal
|
||||
#:set btc_symbol chr(171)
|
||||
#:set mbtc_symbol chr(187)
|
||||
#:set font_light 'gui/kivy/data/fonts/Roboto-Condensed.ttf'
|
||||
|
||||
<AddressLabel@Label>
|
||||
text_size: self.width, None
|
||||
halign: 'left'
|
||||
valign: 'top'
|
||||
|
||||
<AddressItem@CardItem>
|
||||
address: ''
|
||||
memo: ''
|
||||
amount: ''
|
||||
status: ''
|
||||
BoxLayout:
|
||||
spacing: '8dp'
|
||||
height: '32dp'
|
||||
orientation: 'vertical'
|
||||
Widget
|
||||
AddressLabel:
|
||||
text: root.address
|
||||
shorten: True
|
||||
Widget
|
||||
AddressLabel:
|
||||
text: root.memo
|
||||
color: .699, .699, .699, 1
|
||||
font_size: '13sp'
|
||||
shorten: True
|
||||
Widget
|
||||
BoxLayout:
|
||||
spacing: '8dp'
|
||||
height: '32dp'
|
||||
orientation: 'vertical'
|
||||
Widget
|
||||
AddressLabel:
|
||||
text: root.amount
|
||||
halign: 'right'
|
||||
font_size: '15sp'
|
||||
Widget
|
||||
AddressLabel:
|
||||
text: root.status
|
||||
halign: 'right'
|
||||
font_size: '13sp'
|
||||
color: .699, .699, .699, 1
|
||||
|
||||
AddressScreen:
|
||||
id: addr_screen
|
||||
name: 'address'
|
||||
message: ''
|
||||
pr_status: 'Pending'
|
||||
show_change: False
|
||||
show_used: 0
|
||||
on_message:
|
||||
self.parent.update()
|
||||
BoxLayout
|
||||
padding: '12dp', '70dp', '12dp', '12dp'
|
||||
spacing: '12dp'
|
||||
orientation: 'vertical'
|
||||
size_hint: 1, 1.1
|
||||
BoxLayout:
|
||||
spacing: '6dp'
|
||||
size_hint: 1, None
|
||||
orientation: 'horizontal'
|
||||
AddressFilter:
|
||||
opacity: 1
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
spacing: '5dp'
|
||||
AddressButton:
|
||||
id: search
|
||||
text: _('Change') if root.show_change else _('Receiving')
|
||||
on_release:
|
||||
root.show_change = not root.show_change
|
||||
Clock.schedule_once(lambda dt: app.address_screen.update())
|
||||
AddressFilter:
|
||||
opacity: 1
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
spacing: '5dp'
|
||||
AddressButton:
|
||||
id: search
|
||||
text: {0:_('All'), 1:_('Unused'), 2:_('Funded'), 3:_('Used')}[root.show_used]
|
||||
on_release:
|
||||
root.show_used = (root.show_used + 1) % 4
|
||||
Clock.schedule_once(lambda dt: app.address_screen.update())
|
||||
AddressFilter:
|
||||
opacity: 1
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
spacing: '5dp'
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0.9, 0.9, 0.9, 1
|
||||
AddressButton:
|
||||
id: change
|
||||
text: root.message if root.message else _('Search')
|
||||
on_release: Clock.schedule_once(lambda dt: app.description_dialog(addr_screen))
|
||||
ScrollView:
|
||||
GridLayout:
|
||||
cols: 1
|
||||
id: search_container
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
spacing: '2dp'
|
|
@ -1,111 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>Payment request</title>
|
||||
<script type="text/javascript" charset="utf-8" src="jquery-1.9.1.min.js"></script>
|
||||
<script type="text/javascript" src="qrcode.js"></script>
|
||||
<script type="text/javascript" src="jquery-ui.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="jquery-ui.css">
|
||||
<script type="text/javascript">
|
||||
function getUrlParameter(sParam)
|
||||
{
|
||||
var sPageURL = window.location.search.substring(1);
|
||||
var sURLVariables = sPageURL.split('&');
|
||||
for (var i = 0; i < sURLVariables.length; i++)
|
||||
{
|
||||
var sParameterName = sURLVariables[i].split('=');
|
||||
if (sParameterName[0] == sParam)
|
||||
{
|
||||
return sParameterName[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var id = getUrlParameter('id');
|
||||
|
||||
if (id) {
|
||||
var uri_path = location.pathname;
|
||||
var jqxhr = $.getJSON(uri_path.replace("index.html", "req/"+ id[0] + "/"+ id[1] + "/"+ id + "/"+ id + ".json"), function() {
|
||||
console.log("getJSON:success");
|
||||
})
|
||||
.done( function(data) {
|
||||
new QRCode(document.getElementById("qrcode"), data.URI);
|
||||
$("<p />").text(data.memo).appendTo($("p#reason"));
|
||||
$("<p />").text(data.amount/100000000 + "ZEC").appendTo($("p#amount"));
|
||||
$("a").attr("href", data.URI);
|
||||
$("<p />").text("Powered by Electrum-Zcash").appendTo($("p#powered"));
|
||||
var websocket_server = data.websocket_server;
|
||||
var websocket_port = data.websocket_port;
|
||||
$(function () {
|
||||
var current;
|
||||
var max = 100;
|
||||
var initial = data.time;
|
||||
var duration = data.exp;
|
||||
if(duration){
|
||||
var current = 100 * (Math.floor(Date.now()/1000) - initial)/duration;
|
||||
$("#progressbar").progressbar({
|
||||
value: current,
|
||||
max: max
|
||||
});
|
||||
function update() {
|
||||
current = 100 * (Math.floor(Date.now()/1000) - initial)/duration;
|
||||
$("#progressbar").progressbar({
|
||||
value: current
|
||||
});
|
||||
if (current >= max) {
|
||||
$("#container").html("This invoice has expired");
|
||||
}
|
||||
};
|
||||
var interval = setInterval(update, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
var wss_address = "wss://" + websocket_server + ":" + websocket_port +"/";
|
||||
console.log("Opening WSS: " + wss_address)
|
||||
var ws = new WebSocket(wss_address);
|
||||
|
||||
ws.onopen = function() {
|
||||
ws.send('id:' + id);
|
||||
};
|
||||
ws.onmessage = function (evt) {
|
||||
var received_msg = evt.data;
|
||||
if(received_msg == 'paid'){
|
||||
$("#container").html("This invoice has been paid.");
|
||||
}
|
||||
else alert("Message is received:"+ received_msg);
|
||||
};
|
||||
|
||||
})
|
||||
.fail(function() {
|
||||
console.log("error fail");
|
||||
$("<p />").text("error").appendTo($("p#error"));
|
||||
});
|
||||
};
|
||||
|
||||
// See http://stackoverflow.com/questions/29186154/chrome-clicking-mailto-links-closes-websocket-connection
|
||||
$(document).on('click', 'a[href^="zcash:"]', function (e) {
|
||||
e.preventDefault();
|
||||
var zcashWindow = window.open($(e.currentTarget).attr('href'));
|
||||
zcashWindow.close();
|
||||
return false;
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container" style="width:20em; text-align:center; margin:auto; font-family:arial, serif;">
|
||||
<p id="error"></p>
|
||||
<p id="reason"></p>
|
||||
<p id="amount"></p>
|
||||
<div style="background-color:#7777aa; border-radius: 5px; padding:10px;">
|
||||
<a style="color:#ffffff; text-decoration:none;" id="paylink" target="_blank">Pay with Zcash</a>
|
||||
</div>
|
||||
<br/>
|
||||
<div id="qrcode" align="center"></div>
|
||||
<p id="powered" style="font-size:80%;"></p>
|
||||
<div id="progressbar"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,374 +0,0 @@
|
|||
import threading
|
||||
|
||||
from binascii import hexlify, unhexlify
|
||||
|
||||
from electrum_zcash.util import bfh, bh2u
|
||||
from electrum_zcash.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
|
||||
TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants)
|
||||
from electrum_zcash.i18n import _
|
||||
from electrum_zcash.plugins import BasePlugin
|
||||
from electrum_zcash.transaction import deserialize
|
||||
from electrum_zcash.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey
|
||||
|
||||
from ..hw_wallet import HW_PluginBase
|
||||
|
||||
|
||||
# TREZOR initialization methods
|
||||
TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, TIM_PRIVKEY = range(0, 4)
|
||||
|
||||
class TrezorCompatibleKeyStore(Hardware_KeyStore):
|
||||
|
||||
def get_derivation(self):
|
||||
return self.derivation
|
||||
|
||||
def get_client(self, force_pair=True):
|
||||
return self.plugin.get_client(self, force_pair)
|
||||
|
||||
def decrypt_message(self, sequence, message, password):
|
||||
raise RuntimeError(_('Encryption and decryption are not implemented by %s') % self.device)
|
||||
|
||||
def sign_message(self, sequence, message, password):
|
||||
client = self.get_client()
|
||||
address_path = self.get_derivation() + "/%d/%d"%sequence
|
||||
address_n = client.expand_path(address_path)
|
||||
msg_sig = client.sign_message(self.plugin.get_coin_name(), address_n, message)
|
||||
return msg_sig.signature
|
||||
|
||||
def sign_transaction(self, tx, password):
|
||||
if tx.is_complete():
|
||||
return
|
||||
# previous transactions used as inputs
|
||||
prev_tx = {}
|
||||
# path of the xpubs that are involved
|
||||
xpub_path = {}
|
||||
for txin in tx.inputs():
|
||||
pubkeys, x_pubkeys = tx.get_sorted_pubkeys(txin)
|
||||
tx_hash = txin['prevout_hash']
|
||||
prev_tx[tx_hash] = txin['prev_tx']
|
||||
for x_pubkey in x_pubkeys:
|
||||
if not is_xpubkey(x_pubkey):
|
||||
continue
|
||||
xpub, s = parse_xpubkey(x_pubkey)
|
||||
if xpub == self.get_master_public_key():
|
||||
xpub_path[xpub] = self.get_derivation()
|
||||
|
||||
self.plugin.sign_transaction(self, tx, prev_tx, xpub_path)
|
||||
|
||||
|
||||
class TrezorCompatiblePlugin(HW_PluginBase):
|
||||
# Derived classes provide:
|
||||
#
|
||||
# class-static variables: client_class, firmware_URL, handler_class,
|
||||
# libraries_available, libraries_URL, minimum_firmware,
|
||||
# wallet_class, ckd_public, types, HidTransport
|
||||
|
||||
MAX_LABEL_LEN = 32
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
HW_PluginBase.__init__(self, parent, config, name)
|
||||
self.main_thread = threading.current_thread()
|
||||
# FIXME: move to base class when Ledger is fixed
|
||||
if self.libraries_available:
|
||||
self.device_manager().register_devices(self.DEVICE_IDS)
|
||||
|
||||
def _try_hid(self, device):
|
||||
self.print_error("Trying to connect over USB...")
|
||||
if device.interface_number == 1:
|
||||
pair = [None, device.path]
|
||||
else:
|
||||
pair = [device.path, None]
|
||||
|
||||
try:
|
||||
return self.hid_transport(pair)
|
||||
except BaseException as e:
|
||||
# see fdb810ba622dc7dbe1259cbafb5b28e19d2ab114
|
||||
# raise
|
||||
self.print_error("cannot connect at", device.path, str(e))
|
||||
return None
|
||||
|
||||
def _try_bridge(self, device):
|
||||
self.print_error("Trying to connect over Trezor Bridge...")
|
||||
try:
|
||||
return self.bridge_transport({'path': hexlify(device.path)})
|
||||
except BaseException as e:
|
||||
self.print_error("cannot connect to bridge", str(e))
|
||||
return None
|
||||
|
||||
def create_client(self, device, handler):
|
||||
# disable bridge because it seems to never returns if keepkey is plugged
|
||||
#transport = self._try_bridge(device) or self._try_hid(device)
|
||||
transport = self._try_hid(device)
|
||||
if not transport:
|
||||
self.print_error("cannot connect to device")
|
||||
return
|
||||
|
||||
self.print_error("connected to device at", device.path)
|
||||
|
||||
client = self.client_class(transport, handler, self)
|
||||
|
||||
# Try a ping for device sanity
|
||||
try:
|
||||
client.ping('t')
|
||||
except BaseException as e:
|
||||
self.print_error("ping failed", str(e))
|
||||
return None
|
||||
|
||||
if not client.atleast_version(*self.minimum_firmware):
|
||||
msg = (_('Outdated %s firmware for device labelled %s. Please '
|
||||
'download the updated firmware from %s') %
|
||||
(self.device, client.label(), self.firmware_URL))
|
||||
self.print_error(msg)
|
||||
handler.show_error(msg)
|
||||
return None
|
||||
|
||||
return client
|
||||
|
||||
def get_client(self, keystore, force_pair=True):
|
||||
devmgr = self.device_manager()
|
||||
handler = keystore.handler
|
||||
with devmgr.hid_lock:
|
||||
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
|
||||
# returns the client for a given keystore. can use xpub
|
||||
if client:
|
||||
client.used()
|
||||
return client
|
||||
|
||||
def get_coin_name(self):
|
||||
return "Zcash Testnet" if NetworkConstants.TESTNET else "Zcash"
|
||||
|
||||
def initialize_device(self, device_id, wizard, handler):
|
||||
# Initialization method
|
||||
msg = _("Choose how you want to initialize your %s.\n\n"
|
||||
"The first two methods are secure as no secret information "
|
||||
"is entered into your computer.\n\n"
|
||||
"For the last two methods you input secrets on your keyboard "
|
||||
"and upload them to your %s, and so you should "
|
||||
"only do those on a computer you know to be trustworthy "
|
||||
"and free of malware."
|
||||
) % (self.device, self.device)
|
||||
choices = [
|
||||
# Must be short as QT doesn't word-wrap radio button text
|
||||
(TIM_NEW, _("Let the device generate a completely new seed randomly")),
|
||||
(TIM_RECOVER, _("Recover from a seed you have previously written down")),
|
||||
(TIM_MNEMONIC, _("Upload a BIP39 mnemonic to generate the seed")),
|
||||
(TIM_PRIVKEY, _("Upload a master private key"))
|
||||
]
|
||||
def f(method):
|
||||
import threading
|
||||
settings = self.request_trezor_init_settings(wizard, method, self.device)
|
||||
t = threading.Thread(target = self._initialize_device, args=(settings, method, device_id, wizard, handler))
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
wizard.loop.exec_()
|
||||
wizard.choice_dialog(title=_('Initialize Device'), message=msg, choices=choices, run_next=f)
|
||||
|
||||
def _initialize_device(self, settings, method, device_id, wizard, handler):
|
||||
item, label, pin_protection, passphrase_protection = settings
|
||||
|
||||
if method == TIM_RECOVER:
|
||||
# FIXME the PIN prompt will appear over this message
|
||||
# which makes this unreadable
|
||||
handler.show_error(_(
|
||||
"You will be asked to enter 24 words regardless of your "
|
||||
"seed's actual length. If you enter a word incorrectly or "
|
||||
"misspell it, you cannot change it or go back - you will need "
|
||||
"to start again from the beginning.\n\nSo please enter "
|
||||
"the words carefully!"))
|
||||
|
||||
language = 'english'
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
|
||||
if method == TIM_NEW:
|
||||
strength = 64 * (item + 2) # 128, 192 or 256
|
||||
u2f_counter = 0
|
||||
skip_backup = False
|
||||
client.reset_device(True, strength, passphrase_protection,
|
||||
pin_protection, label, language,
|
||||
u2f_counter, skip_backup)
|
||||
elif method == TIM_RECOVER:
|
||||
word_count = 6 * (item + 2) # 12, 18 or 24
|
||||
client.step = 0
|
||||
client.recovery_device(word_count, passphrase_protection,
|
||||
pin_protection, label, language)
|
||||
elif method == TIM_MNEMONIC:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_mnemonic(str(item), pin,
|
||||
passphrase_protection,
|
||||
label, language)
|
||||
else:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_xprv(item, pin, passphrase_protection,
|
||||
label, language)
|
||||
wizard.loop.exit(0)
|
||||
|
||||
def setup_device(self, device_info, wizard):
|
||||
'''Called when creating a new wallet. Select the device to use. If
|
||||
the device is uninitialized, go through the intialization
|
||||
process.'''
|
||||
devmgr = self.device_manager()
|
||||
device_id = device_info.device.id_
|
||||
client = devmgr.client_by_id(device_id)
|
||||
# fixme: we should use: client.handler = wizard
|
||||
client.handler = self.create_handler(wizard)
|
||||
if not device_info.initialized:
|
||||
self.initialize_device(device_id, wizard, client.handler)
|
||||
client.get_xpub('m', 'standard')
|
||||
client.used()
|
||||
|
||||
def get_xpub(self, device_id, derivation, xtype, wizard):
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = wizard
|
||||
xpub = client.get_xpub(derivation, xtype)
|
||||
client.used()
|
||||
return xpub
|
||||
|
||||
def sign_transaction(self, keystore, tx, prev_tx, xpub_path):
|
||||
self.prev_tx = prev_tx
|
||||
self.xpub_path = xpub_path
|
||||
client = self.get_client(keystore)
|
||||
inputs = self.tx_inputs(tx, True)
|
||||
outputs = self.tx_outputs(keystore.get_derivation(), tx)
|
||||
signed_tx = client.sign_tx(self.get_coin_name(), inputs, outputs, lock_time=tx.locktime)[1]
|
||||
raw = bh2u(signed_tx)
|
||||
tx.update_signatures(raw)
|
||||
|
||||
def show_address(self, wallet, address):
|
||||
client = self.get_client(wallet.keystore)
|
||||
if not client.atleast_version(1, 3):
|
||||
wallet.keystore.handler.show_error(_("Your device firmware is too old"))
|
||||
return
|
||||
change, index = wallet.get_address_index(address)
|
||||
derivation = wallet.keystore.derivation
|
||||
address_path = "%s/%d/%d"%(derivation, change, index)
|
||||
address_n = client.expand_path(address_path)
|
||||
script_type = self.types.SPENDADDRESS
|
||||
client.get_address(self.get_coin_name(), address_n, True, script_type=script_type)
|
||||
|
||||
def tx_inputs(self, tx, for_sig=False):
|
||||
inputs = []
|
||||
for txin in tx.inputs():
|
||||
txinputtype = self.types.TxInputType()
|
||||
if txin['type'] == 'coinbase':
|
||||
prev_hash = "\0"*32
|
||||
prev_index = 0xffffffff # signed int -1
|
||||
else:
|
||||
if for_sig:
|
||||
x_pubkeys = txin['x_pubkeys']
|
||||
if len(x_pubkeys) == 1:
|
||||
x_pubkey = x_pubkeys[0]
|
||||
xpub, s = parse_xpubkey(x_pubkey)
|
||||
xpub_n = self.client_class.expand_path(self.xpub_path[xpub])
|
||||
txinputtype.address_n.extend(xpub_n + s)
|
||||
txinputtype.script_type = self.types.SPENDADDRESS
|
||||
else:
|
||||
def f(x_pubkey):
|
||||
if is_xpubkey(x_pubkey):
|
||||
xpub, s = parse_xpubkey(x_pubkey)
|
||||
else:
|
||||
xpub = xpub_from_pubkey(0, bfh(x_pubkey))
|
||||
s = []
|
||||
node = self.ckd_public.deserialize(xpub)
|
||||
return self.types.HDNodePathType(node=node, address_n=s)
|
||||
pubkeys = map(f, x_pubkeys)
|
||||
multisig = self.types.MultisigRedeemScriptType(
|
||||
pubkeys=pubkeys,
|
||||
signatures=map(lambda x: bfh(x)[:-1] if x else b'', txin.get('signatures')),
|
||||
m=txin.get('num_sig'),
|
||||
)
|
||||
script_type = self.types.SPENDMULTISIG
|
||||
txinputtype = self.types.TxInputType(
|
||||
script_type=script_type,
|
||||
multisig=multisig
|
||||
)
|
||||
# find which key is mine
|
||||
for x_pubkey in x_pubkeys:
|
||||
if is_xpubkey(x_pubkey):
|
||||
xpub, s = parse_xpubkey(x_pubkey)
|
||||
if xpub in self.xpub_path:
|
||||
xpub_n = self.client_class.expand_path(self.xpub_path[xpub])
|
||||
txinputtype.address_n.extend(xpub_n + s)
|
||||
break
|
||||
|
||||
prev_hash = unhexlify(txin['prevout_hash'])
|
||||
prev_index = txin['prevout_n']
|
||||
|
||||
if 'value' in txin:
|
||||
txinputtype.amount = txin['value']
|
||||
txinputtype.prev_hash = prev_hash
|
||||
txinputtype.prev_index = prev_index
|
||||
|
||||
if 'scriptSig' in txin:
|
||||
script_sig = bfh(txin['scriptSig'])
|
||||
txinputtype.script_sig = script_sig
|
||||
|
||||
txinputtype.sequence = txin.get('sequence', 0xffffffff - 1)
|
||||
|
||||
inputs.append(txinputtype)
|
||||
|
||||
return inputs
|
||||
|
||||
def tx_outputs(self, derivation, tx):
|
||||
outputs = []
|
||||
has_change = False
|
||||
|
||||
for _type, address, amount in tx.outputs():
|
||||
info = tx.output_info.get(address)
|
||||
if info is not None and not has_change:
|
||||
has_change = True # no more than one change address
|
||||
addrtype, hash_160 = b58_address_to_hash160(address)
|
||||
index, xpubs, m = info
|
||||
if len(xpubs) == 1:
|
||||
script_type = self.types.PAYTOADDRESS
|
||||
address_n = self.client_class.expand_path(derivation + "/%d/%d"%index)
|
||||
txoutputtype = self.types.TxOutputType(
|
||||
amount = amount,
|
||||
script_type = script_type,
|
||||
address_n = address_n,
|
||||
)
|
||||
else:
|
||||
script_type = self.types.PAYTOMULTISIG
|
||||
address_n = self.client_class.expand_path("/%d/%d"%index)
|
||||
nodes = map(self.ckd_public.deserialize, xpubs)
|
||||
pubkeys = [ self.types.HDNodePathType(node=node, address_n=address_n) for node in nodes]
|
||||
multisig = self.types.MultisigRedeemScriptType(
|
||||
pubkeys = pubkeys,
|
||||
signatures = [b''] * len(pubkeys),
|
||||
m = m)
|
||||
txoutputtype = self.types.TxOutputType(
|
||||
multisig = multisig,
|
||||
amount = amount,
|
||||
address_n = self.client_class.expand_path(derivation + "/%d/%d"%index),
|
||||
script_type = script_type)
|
||||
else:
|
||||
txoutputtype = self.types.TxOutputType()
|
||||
txoutputtype.amount = amount
|
||||
if _type == TYPE_SCRIPT:
|
||||
txoutputtype.script_type = self.types.PAYTOOPRETURN
|
||||
txoutputtype.op_return_data = address[2:]
|
||||
elif _type == TYPE_ADDRESS:
|
||||
txoutputtype.script_type = self.types.PAYTOADDRESS
|
||||
txoutputtype.address = address
|
||||
|
||||
outputs.append(txoutputtype)
|
||||
|
||||
return outputs
|
||||
|
||||
def electrum_tx_to_txtype(self, tx):
|
||||
t = self.types.TransactionType()
|
||||
d = deserialize(tx.raw)
|
||||
t.version = d['version']
|
||||
t.lock_time = d['lockTime']
|
||||
inputs = self.tx_inputs(tx)
|
||||
t.inputs.extend(inputs)
|
||||
for vout in d['outputs']:
|
||||
o = t.bin_outputs.add()
|
||||
o.amount = vout['value']
|
||||
o.script_pubkey = bfh(vout['scriptPubKey'])
|
||||
return t
|
||||
|
||||
# This function is called from the trezor libraries (via tx_api)
|
||||
def get_tx(self, tx_hash):
|
||||
tx = self.prev_tx[tx_hash]
|
||||
return self.electrum_tx_to_txtype(tx)
|
Loading…
Reference in New Issue