Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: collaterals being spent when creating protx #400

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions ansible/roles/mn_createprotx/tasks/createprovidertx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

- name: Verify fee balance is ready to spend
ansible.builtin.command: >
dash-cli getaddressbalance '{"addresses": ["{{ masternode.collateral.address }}"]}'
dash-cli getaddressbalance '{"addresses": ["{{ fee_address.stdout }}"]}'
retries: 10
delay: 1
register: result
until: result.stdout | from_json | json_query('balance_spendable') | int > 100000000000
until: result.stdout | from_json | json_query('balance_spendable') | int >= 100000000
changed_when: result.stdout | length > 0

- name: Create ProTx for {{ masternode_name ~ '/' ~ masternode.owner.address }}
Expand All @@ -21,6 +21,6 @@
{{ masternode.owner.address }}
0
{{ miner_payment_address }}
{{ masternode.collateral.address }}"
{{ fee_address.stdout }}"
register: protx
changed_when: protx.stdout | length == 64
34 changes: 9 additions & 25 deletions ansible/roles/mn_createprotx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,17 @@

# fund fee

- name: Populate fee payment targets
ansible.builtin.set_fact:
fee_target_addresses: "{{ fee_target_addresses | default([]) + [masternodes[item].collateral.address] }}"
with_items:
- "{{ masternode_names }}"

- name: Check if address contains a suitable fee utxo
ansible.builtin.command: >
dash-cli -rpcwallet={{ wallet_rpc_wallet_mno }} listunspent 1 99999999 '{{ fee_target_addresses | to_json }}' false '{{ maxamount | to_json }}'
register: funded_addresses
changed_when: funded_addresses.stdout | from_json | length > 0
vars:
maxamount:
maximumAmount: 1
- name: Get new fee address
ansible.builtin.command: 'dash-cli -rpcwallet={{ wallet_rpc_wallet_mno }} getnewaddress'
register: fee_address
changed_when: fee_address.stdout | length == 34

- name: Figure out which addresses need fee funding
ansible.builtin.set_fact:
fee_missing_addresses: "{{ fee_target_addresses | difference(funded_addresses.stdout) }}"

- name: Fund 1 coin for ProTx fee
ansible.builtin.include_tasks: ./roles/mn_fund_collateral/tasks/fund_collateral.yml
vars:
amount: 1
payment_targets: '{{ fee_target_addresses }}'
when: fee_target_addresses|length > 0
- name: Fund fee address
ansible.builtin.command: 'dash-cli -rpcwallet={{ wallet_rpc_wallet_faucet }} sendtoaddress {{ fee_address.stdout }} 10'
register: fund_result
changed_when: fund_result.stdout | length == 64

- name: Generate at least one block to confirm fee funding transactions
- name: Generate at least one block to confirm fee funding transaction
ansible.builtin.include_role:
name: generate_blocks
vars:
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/mn_unban/tasks/createproupservtx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
{{ hostvars[masternode_name].public_ip }}:{{ dashd_port }}
{{ masternode.operator.private_key }}
''
{{ masternode.collateral.address }}" # Should already be funded from registration protx
{{ fee_address.stdout }}" # Should already be funded from registration protx
register: protx
changed_when: protx.stdout | length == 64