|
@ -206,13 +206,13 @@ class Commands: |
|
|
return t |
|
|
return t |
|
|
|
|
|
|
|
|
@command('') |
|
|
@command('') |
|
|
def decodetx(self, tx): |
|
|
def deserialize(self, tx): |
|
|
"""Decode serialized transaction""" |
|
|
"""Deserialize a serialized transaction""" |
|
|
t = Transaction(tx) |
|
|
t = Transaction(tx) |
|
|
return t.deserialize() |
|
|
return t.deserialize() |
|
|
|
|
|
|
|
|
@command('n') |
|
|
@command('n') |
|
|
def sendtx(self, tx): |
|
|
def broadcast(self, tx): |
|
|
"""Broadcast a transaction to the network. """ |
|
|
"""Broadcast a transaction to the network. """ |
|
|
t = Transaction(tx) |
|
|
t = Transaction(tx) |
|
|
return self.network.synchronous_get([('blockchain.transaction.broadcast', [str(t)])])[0] |
|
|
return self.network.synchronous_get([('blockchain.transaction.broadcast', [str(t)])])[0] |
|
@ -357,7 +357,7 @@ class Commands: |
|
|
"""Verify a signature.""" |
|
|
"""Verify a signature.""" |
|
|
return bitcoin.verify_message(address, signature, message) |
|
|
return bitcoin.verify_message(address, signature, message) |
|
|
|
|
|
|
|
|
def _mktx(self, outputs, fee, change_addr, domain, nocheck, unsigned, deserialized): |
|
|
def _mktx(self, outputs, fee, change_addr, domain, nocheck, unsigned): |
|
|
resolver = lambda x: None if x is None else self.contacts.resolve(x, nocheck)['address'] |
|
|
resolver = lambda x: None if x is None else self.contacts.resolve(x, nocheck)['address'] |
|
|
change_addr = resolver(change_addr) |
|
|
change_addr = resolver(change_addr) |
|
|
domain = None if domain is None else map(resolver, domain) |
|
|
domain = None if domain is None else map(resolver, domain) |
|
@ -386,7 +386,7 @@ class Commands: |
|
|
str(tx) #this serializes |
|
|
str(tx) #this serializes |
|
|
if not unsigned: |
|
|
if not unsigned: |
|
|
self.wallet.sign_transaction(tx, self.password) |
|
|
self.wallet.sign_transaction(tx, self.password) |
|
|
return tx.deserialize() if deserialized else tx |
|
|
return tx |
|
|
|
|
|
|
|
|
def _read_csv(self, csvpath): |
|
|
def _read_csv(self, csvpath): |
|
|
import csv |
|
|
import csv |
|
@ -401,36 +401,27 @@ class Commands: |
|
|
return outputs |
|
|
return outputs |
|
|
|
|
|
|
|
|
@command('wp') |
|
|
@command('wp') |
|
|
def mktx(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False): |
|
|
def payto(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False, broadcast=False): |
|
|
"""Create a transaction. """ |
|
|
"""Create a transaction. """ |
|
|
domain = [from_addr] if from_addr else None |
|
|
domain = [from_addr] if from_addr else None |
|
|
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck, unsigned, deserialized) |
|
|
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck, unsigned) |
|
|
return tx |
|
|
if broadcast: |
|
|
|
|
|
r, h = self.wallet.sendtx(tx) |
|
|
|
|
|
return h |
|
|
|
|
|
else: |
|
|
|
|
|
return tx.deserialize() if deserialized else tx |
|
|
|
|
|
|
|
|
@command('wp') |
|
|
@command('wp') |
|
|
def mktx_csv(self, csv_file, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False): |
|
|
def paytomany(self, csv_file, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False, broadcast=False): |
|
|
"""Create a multi-output transaction. """ |
|
|
"""Create a multi-output transaction. """ |
|
|
domain = [from_addr] if from_addr else None |
|
|
domain = [from_addr] if from_addr else None |
|
|
outputs = self._read_csv(csv_file) |
|
|
outputs = self._read_csv(csv_file) |
|
|
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck, unsigned, deserialized) |
|
|
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck, unsigned) |
|
|
return tx |
|
|
if broadcast: |
|
|
|
|
|
r, h = self.wallet.sendtx(tx) |
|
|
@command('wpn') |
|
|
return h |
|
|
def payto(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False): |
|
|
else: |
|
|
"""Create and broadcast a transaction.. """ |
|
|
return tx.deserialize() if deserialized else tx |
|
|
domain = [from_addr] if from_addr else None |
|
|
|
|
|
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck) |
|
|
|
|
|
r, h = self.wallet.sendtx(tx) |
|
|
|
|
|
return h |
|
|
|
|
|
|
|
|
|
|
|
@command('wpn') |
|
|
|
|
|
def payto_csv(self, csv_file, tx_fee=None, from_addr=None, change_addr=None, nocheck=False): |
|
|
|
|
|
"""Create and broadcast multi-output transaction.. """ |
|
|
|
|
|
domain = [from_addr] if from_addr else None |
|
|
|
|
|
outputs = self._read_csv(csv_file) |
|
|
|
|
|
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck) |
|
|
|
|
|
r, h = self.wallet.sendtx(tx) |
|
|
|
|
|
return h |
|
|
|
|
|
|
|
|
|
|
|
@command('wn') |
|
|
@command('wn') |
|
|
def history(self): |
|
|
def history(self): |
|
@ -581,6 +572,7 @@ param_descriptions = { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
command_options = { |
|
|
command_options = { |
|
|
|
|
|
'broadcast': (None, "--broadcast", "Broadcast the transaction to the Bitcoin network"), |
|
|
'password': ("-W", "--password", "Password"), |
|
|
'password': ("-W", "--password", "Password"), |
|
|
'concealed': ("-C", "--concealed", "Don't echo seed to console when restoring"), |
|
|
'concealed': ("-C", "--concealed", "Don't echo seed to console when restoring"), |
|
|
'show_all': ("-a", "--all", "Include change addresses"), |
|
|
'show_all': ("-a", "--all", "Include change addresses"), |
|
|