Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ coverage.xml
# Django stuff:
*.log
*.pot
.idea/
6 changes: 5 additions & 1 deletion blockcypher/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ def broadcast_signed_transaction(unsigned_tx, signatures, pubkeys, coin_symbol='


def simple_spend(from_privkey, to_address, to_satoshis, change_address=None,
privkey_is_compressed=True, min_confirmations=0, api_key=None, coin_symbol='btc'):
privkey_is_compressed=True, min_confirmations=0, api_key=None, coin_symbol='btc', preference: str = 'low'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a better UX I suggest that keep the fee high here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback @quentinlesceller. I plan making the needed changes. Also noticed a similar need for the function simple_spend_p2sh. Will attempt to make similar changes and add tests as well.

Thanks

'''
Simple method to spend from one single-key address to another.

Expand All @@ -1640,6 +1640,9 @@ def simple_spend(from_privkey, to_address, to_satoshis, change_address=None,
Compressed public keys (and their corresponding addresses) have been the standard since v0.6,
set privkey_is_compressed=False if using uncompressed addresses.

Fees preferences can be set as strings with value 'low', 'medium', 'zero' or 'high'.
Transaction with zero fees are unlikely to be added to a block. This value was

Note that this currently only supports spending from single key addresses.
'''
assert is_valid_coin_symbol(coin_symbol), coin_symbol
Expand Down Expand Up @@ -1673,6 +1676,7 @@ def simple_spend(from_privkey, to_address, to_satoshis, change_address=None,
verify_tosigntx=False, # will verify in next step
include_tosigntx=True,
api_key=api_key,
preference=preference if preference in ('high', 'medium', 'low', 'zero') else 'high'
)
logger.info('unsigned_tx: %s' % unsigned_tx)

Expand Down
Loading