I could send my asset by using Python script. The sender address was generated on my own bitcoind. The receiver address was generated on counterwallet.io. How can I send my asset from another address which was generated on counterwallet.io? I think I should use the private key explicitly at signing.
I have 3 addresses.
X: generated by my node
Y: generated by counterwallet.io
Z: generated by counterwallet.io
[X] --> [Y] is OK.
[Y] --> [Z] is what I want.
[X] --> [Y]
#! /usr/bin/env python3
import sys
from counterpartylib.lib import util
from counterpartylib.lib import config
from counterpartylib.lib.backend import addrindex
config.BACKEND_URL = 'http://xxx:xxx@localhost:8332'
config.RPC = 'http://xxx:xxx@localhost:4000'
config.BACKEND_SSL_NO_VERIFY = True
config.REQUESTS_TIMEOUT = 20
def counterparty_api(method, params):
return util.api(method, params)
def bitcoin_api(method, params):
return addrindex.rpc(method, params)
def do_send(source, destination, asset, quantity, fee = 0, encoding = 'UTF-8'):
validateaddress = bitcoin_api('validateaddress', [source])
assert validateaddress['ismine']
pubkey = validateaddress['pubkey']
unsigned_tx = counterparty_api('create_send', {'source': source, 'destination': destination, 'asset': asset, 'quantity': int(quantity), 'pubkey': pubkey, 'allow_unconfirmed_inputs': True})
signed_tx = bitcoin_api('signrawtransaction', [unsigned_tx])['hex']
tx_hash = bitcoin_api('sendrawtransaction', [signed_tx])
return tx_hash
# Send to one
do_send(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
I’m doing trial and error.
[Y] --> [Z]
def do_send(source, destination, asset, quantity, fee = 0, encoding = 'UTF-8'):
#validateaddress = bitcoin_api('validateaddress', [source])
#assert validateaddress['ismine']
#pubkey = validateaddress['pubkey']
pubkey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ← I got pubkey from private key
unsigned_tx = counterparty_api('create_send', {'source': source, 'destination': destination, 'asset': asset, 'quantity': int(quantity), 'pubkey': pubkey, 'allow_unconfirmed_inputs': True})
#signed_tx = bitcoin_api('signrawtransaction', [unsigned_tx])['hex']
signed_tx = bitcoin_api('signrawtransaction', [unsigned_tx] ['xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'])['hex'] ← Not sure this point
tx_hash = bitcoin_api('sendrawtransaction', [signed_tx])
return tx_hash