Пример #1
0
 def call_send(self, instance):
     address = self.sendaddress.text
     if not address or address[0] != "1":
         # should show a popup here
         print "Invalid address"
         return
     amount_satoshis = int(D(self.amount_mbtc.text) * 10**5)
     # debug
     print 'should send', str(amount_satoshis) ,'to address', address
     # TODO validate address
     # TODO call backend send function
     fee = 10000
     optimal_outputs = self.backend.select_outputs(amount_satoshis + fee)
     print optimal_outputs
     if optimal_outputs is None:
         self.show_invalid_balance_popup()
         return
     # Add inputs
     tx = obelisk.Transaction()
     for output in optimal_outputs.points:
         add_input(tx, output.point)
     add_output(tx, address, amount_satoshis)
     # Change output.
     change = optimal_outputs.change - fee
     add_output(tx, self.backend.current_change_address, change)
     for i, output in enumerate(optimal_outputs.points):
         obelisk.sign_transaction_input(tx, i, output.key)
     #print tx.serialize().encode("hex")
     self.backend.broadcast(tx)
Пример #2
0
 def call_send(self, instance):
     address = self.sendaddress.text
     if not address or address[0] != "1":
         # should show a popup here
         print "Invalid address"
         return
     amount_satoshis = int(D(self.amount_mbtc.text) * 10**5)
     # debug
     print 'should send', str(amount_satoshis), 'to address', address
     # TODO validate address
     # TODO call backend send function
     fee = 10000
     optimal_outputs = self.backend.select_outputs(amount_satoshis + fee)
     print optimal_outputs
     if optimal_outputs is None:
         self.show_invalid_balance_popup()
         return
     # Add inputs
     tx = obelisk.Transaction()
     for output in optimal_outputs.points:
         add_input(tx, output.point)
     add_output(tx, address, amount_satoshis)
     # Change output.
     change = optimal_outputs.change - fee
     add_output(tx, self.backend.current_change_address, change)
     for i, output in enumerate(optimal_outputs.points):
         obelisk.sign_transaction_input(tx, i, output.key)
     #print tx.serialize().encode("hex")
     self.backend.broadcast(tx)
Пример #3
0
def build_actual_tx(unspent, root_hash):
    print "Building...", root_hash.encode("hex")
    fee = 10000
    optimal_outputs = obelisk.select_outputs(unspent, fee)
    tx = obelisk.Transaction()
    for output in optimal_outputs.points:
        add_input(tx, output.point)
    add_return_output(tx, root_hash)
    change = optimal_outputs.change
    add_output(tx, address, change)
    key = obelisk.EllipticCurveKey()
    key.set_secret(secret)
    for i, output in enumerate(optimal_outputs.points):
        obelisk.sign_transaction_input(tx, i, key)
    broadcast.broadcast(tx)
    tx_hash = hash_transaction(tx)
    return tx_hash
Пример #4
0
def build_actual_tx(unspent, root_hash):
    print "Building...", root_hash.encode("hex")
    fee = 10000
    optimal_outputs = obelisk.select_outputs(unspent, fee)
    tx = obelisk.Transaction()
    for output in optimal_outputs.points:
        add_input(tx, output.point)
    add_return_output(tx, root_hash)
    change = optimal_outputs.change
    add_output(tx, address, change)
    key = obelisk.EllipticCurveKey()
    key.set_secret(secret)
    for i, output in enumerate(optimal_outputs.points):
        obelisk.sign_transaction_input(tx, i, key)
    broadcast.broadcast(tx)
    tx_hash = hash_transaction(tx)
    return tx_hash
Пример #5
0
def main(argv):
    tx = obelisk.Transaction()
    for switch, param in zip(argv[1::2], argv[2::2]):
        if switch == "-i":
            tx_hash, tx_index = param.split(":")
            tx_hash = tx_hash.decode("hex")
            tx_index = int(tx_index)
            add_input(tx, tx_hash, tx_index)
        elif switch == "-o":
            address, value = param.split(":")
            value = D(value)
            add_output(tx, address, value)
    # initialize signing key
    key = obelisk.EllipticCurveKey()
    secret = "59cd7a1d11ef24a1687b7c20bdb9f3bb" \
             "1cb93908401c503f8d69521dbfcd1c6d".decode("hex")
    assert len(secret) == 32
    key.set_secret(secret)
    # sign input 0
    obelisk.sign_transaction_input(tx, 0, key)
    print tx
    print tx.serialize().encode("hex")