Fix make_change to not create half-satoshis
This commit is contained in:
parent
b8d92236f6
commit
3a7c3483b6
@ -10,7 +10,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc"))
|
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc"))
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal, ROUND_DOWN
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
@ -230,10 +230,12 @@ def make_change(from_node, amount_in, amount_out, fee):
|
|||||||
change = amount_in - amount
|
change = amount_in - amount
|
||||||
if change > amount*2:
|
if change > amount*2:
|
||||||
# Create an extra change output to break up big inputs
|
# Create an extra change output to break up big inputs
|
||||||
outputs[from_node.getnewaddress()] = float(change/2)
|
change_address = from_node.getnewaddress()
|
||||||
change = change/2
|
# Split change in two, being careful of rounding:
|
||||||
|
outputs[change_address] = Decimal(change/2).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
|
||||||
|
change = amount_in - amount - outputs[change_address]
|
||||||
if change > 0:
|
if change > 0:
|
||||||
outputs[from_node.getnewaddress()] = float(change)
|
outputs[from_node.getnewaddress()] = change
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
def send_zeropri_transaction(from_node, to_node, amount, fee):
|
def send_zeropri_transaction(from_node, to_node, amount, fee):
|
||||||
|
Loading…
Reference in New Issue
Block a user