Skip to content

Commit 0b3a5f7

Browse files
authored
Bip32 fix (#50)
* support mixed receiving_address * min fee to 0.000025 for bip32 tx * an explorer add * display total balnce
1 parent 4ce9aac commit 0b3a5f7

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

bin/dashmnb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def main(args):
241241
bip32_unused = None
242242

243243
for m in mn_config:
244+
print("\t---> getting balance of : ", m.get('alias'))
244245
m["txs"], m["collateral_dashd_balance"], m["bip32sendto_all"] = get_unspent_txs(m, blockcount, access, SEND_TO_BIP32, bip32_unused)
245246

246247
need_wallet_rescan = print_balance(mn_config, have_unconfirmed_tx)

dashlib/mnb_explorer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def get_insight_blockcount():
106106

107107
exp = [
108108
"http://insight.dev.dash.org/api",
109+
"https://blockchain.masternode.io/api",
109110
"http://insight.dash.org/api",
110111
"https://insight.dash.siampm.com/api",
111112
"http://insight.masternode.io:3000/api"

dashlib/mnb_maketx.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ def print_balance(mn_config, have_unconfirmed_tx):
1515

1616
need_wallet_rescan = False
1717

18-
print('[masternodes balance]')
18+
print('\n[masternodes balance]')
1919
print('alias\tcnt\tspn\tbalance\t\taddress to send MN earnings')
2020

21+
total_balance = 0
22+
2123
for m in mn_config:
2224
alias = m.get('alias')
2325
unspent = m.get('collateral_dashd_balance')
2426
sumofunspent = sum(unspent)
2527
cnt = len(unspent)
2628

29+
total_balance = total_balance + sumofunspent
30+
2731
spn = 0
2832
txs_spn = m.get('txs')
2933

@@ -49,6 +53,8 @@ def print_balance(mn_config, have_unconfirmed_tx):
4953
'\t' +
5054
str(m.get('receiving_address', '----')))
5155

56+
print('\n\t\t Total : ', total_balance)
57+
5258
print('\n* cnt - count : number of payouts(un + mature) + 1(collateral)')
5359
print('* spn - spenable : number of spendable payouts(mature)')
5460
if have_unconfirmed_tx:
@@ -78,6 +84,7 @@ def get_unspent_txs(mnconfig, blockcount, access, SEND_TO_BIP32, bip32_unused):
7884

7985
collateral_address = mnconfig.get('collateral_address')
8086
collateral_txidtxidn = mnconfig.get('collateral_txidtxidn')
87+
receiving_address = mnconfig.get('receiving_address')
8188

8289
unspent_cache_abs_path = os.path.join(
8390
os.path.dirname(
@@ -124,9 +131,15 @@ def get_unspent_txs(mnconfig, blockcount, access, SEND_TO_BIP32, bip32_unused):
124131
# for testing
125132
#mature_confirmation = 10
126133

134+
desc_displayed = False
135+
127136
for x in unspent_mine:
128137
if (x.get('address') == collateral_address) and ((blockcount - mature_confirmation) > x.get('height')):
129-
if SEND_TO_BIP32 and bip32_unused != None:
138+
if SEND_TO_BIP32 and bip32_unused != None and receiving_address == 'BIP32_PATH':
139+
if not desc_displayed:
140+
print("\t---> getting unused addresses of bip32 path")
141+
desc_displayed = True
142+
130143
bip32sendto_unused = bip32_unused.__next__()
131144
tx = {
132145
"amount": round(Decimal(float(x.get('satoshis') / 1e8)), 8),
@@ -147,7 +160,7 @@ def get_unspent_txs(mnconfig, blockcount, access, SEND_TO_BIP32, bip32_unused):
147160

148161
txs.append(tx)
149162

150-
if SEND_TO_BIP32 and bip32_unused != None:
163+
if SEND_TO_BIP32 and bip32_unused != None and receiving_address == 'BIP32_PATH':
151164
sublist = [txs[i:i + 1] for i in range(0, len(txs), 1)]
152165

153166
else:
@@ -232,11 +245,15 @@ def make_inputs_for_hw_wallet(
232245
if txsizefee == 0:
233246
txsizefee = min_fee
234247

248+
# bip32 1 input tx
249+
if SEND_TO_BIP32 and receiving_address == 'BIP32_PATH':
250+
txsizefee = 2500
251+
235252
# make output based on inputs
236-
if SEND_TO_BIP32:
253+
if SEND_TO_BIP32 and receiving_address == 'BIP32_PATH':
237254
if len(tx) == 1:
238255
bip32sendto = tx[0].get('bip32sendto', None)
239-
if bip32sendto != None:
256+
if bip32sendto != None and receiving_address == 'BIP32_PATH':
240257
outputs.append(
241258
proto_types.TxOutputType(
242259
address=bip32sendto,
@@ -275,8 +292,8 @@ def make_inputs_for_hw_wallet(
275292
script_type=proto_types.PAYTOADDRESS,
276293
))
277294

278-
feetohuman = round(Decimal(txsizefee / 1e8), 4)
279-
if SEND_TO_BIP32:
295+
feetohuman = round(Decimal(txsizefee / 1e8), 6)
296+
if SEND_TO_BIP32 and receiving_address == 'BIP32_PATH':
280297
print('\n\tsend %s\n\t%s txs to %s\n\twith fee of %s\n\ttotal amount : %s\n' % (
281298
amount_total - feetohuman, len(tx), bip32sendto, feetohuman, amount_total))
282299

dashlib/mnb_xfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def broadcast_signedrawtx(mn_config, access, whalemode, SEND_TO_BIP32):
3434

3535
for i in r.get('vout'):
3636
scriptPubKey_addresses = i.get('scriptPubKey').get('addresses')[0]
37-
if SEND_TO_BIP32:
37+
if SEND_TO_BIP32 and vout_addr == 'BIP32_PATH':
3838
if scriptPubKey_addresses not in bip32sendto_all:
3939
err_msg = 'pay_to address is not match with signedrawtx'
4040
print_err_exit(

0 commit comments

Comments
 (0)