티스토리 뷰

전액 출금하지 않고 일부는 기존 주소로 남기겠다고 하실 경우에는,

아래와 같이 입력으로 사용했던 주소를 그대로 출력에 하나 추가해 주시면 됩니다!

from cryptos import *

c = Bitcoin()
from_address = 'address1'
inputs = c.unspent(from_address)
balance =  sum([i['value'] for i in inputs])
fee = 1500
change = 20000  # 2만 사토시는 그대로 잔액으로 남기는 경우,
to = 'address2'
outs = [{'value': balance - fee - change, 'address': to}, {'value': change, 'address': from_address}]
tx = c.mktx(inputs, outs)
signed_tx = c.signall(tx, priv)

# send tx to bitcoin node
c.pushtx(signed_tx)

 

 

블로그내 관련 글

728x90
반응형
댓글
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함