def withdraw(key, to_address, amount=None, dst_tag=None):
    keypair = RawKeypair(key)
    builder = Builder(address=public_key_to_address(keypair.raw_public_key()),
                      network='PUBLIC')

    if amount is None:
        builder.append_account_merge_op(to_address)
    else:
        builder.append_payment_op(to_address, str(round(float(amount), 7)),
                                  'XLM')
    if dst_tag is not None:
        builder.add_text_memo(dst_tag)
    builder.keypair = keypair
    builder.sign()
    ret = builder.submit()
    if ret['successful']:
        return ret['hash']
    print(ret)
    return None
Esempio n. 2
0
async def merge_account(main_address, tmp_address, tmp_seed):
    account = Builder(address=tmp_address, secret=tmp_seed)
    account.append_account_merge_op(destination=main_address)
    account.sign()
    return account.gen_xdr()
async def build_account_merge_operation(builder: Builder, source: str, destination: str):
    builder.append_account_merge_op(destination=destination, source=source)