Skip to content

Instantly share code, notes, and snippets.

@mflaxman
Created September 7, 2017 17:04
Show Gist options
  • Save mflaxman/14e62e46bbc85068fa3d0fd2e00c8df5 to your computer and use it in GitHub Desktop.
Save mflaxman/14e62e46bbc85068fa3d0fd2e00c8df5 to your computer and use it in GitHub Desktop.
Sweep funds from one BTC address to another
from pycoin.tx.tx_utils import create_signed_tx
from pycoin.services.blockcypher import BlockcypherProvider
# inspect your spendables
spendables = [x.as_text() for x in BlockcypherProvider().spendables_for_address(address=FROM_ADDRESS)]
# sign TX
signed_tx = create_signed_tx(
spendables=spendables,
payables=[TO_ADDRESS],
wifs=[WIF],
fee=FEE_IN_SATOSHIS,
)
# inspect signed TX and then use a pushtx service to broadcast
signed_tx.as_hex()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment