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

Resolve getcustomtx call with updatemasternode on owner transfer #1672

Merged
merged 2 commits into from
Dec 27, 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
8 changes: 4 additions & 4 deletions src/masternodes/rpc_customtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class CCustomTxRpcVisitor {
EncodeDestination(addressType == PKHashType ? CTxDestination(PKHash(rawAddress))
: CTxDestination(WitnessV0KeyHash(rawAddress))));
} else if (updateType == static_cast<uint8_t>(UpdateMasternodeType::OwnerAddress)) {
rpcInfo.pushKV(
"ownerAddress",
EncodeDestination(addressType == PKHashType ? CTxDestination(PKHash(rawAddress))
: CTxDestination(WitnessV0KeyHash(rawAddress))));
CTxDestination dest;
if (tx.vout.size() >= 2 && ExtractDestination(tx.vout[1].scriptPubKey, dest)) {
rpcInfo.pushKV("ownerAddress",EncodeDestination(dest));
}
}
if (updateType == static_cast<uint8_t>(UpdateMasternodeType::SetRewardAddress)) {
rpcInfo.pushKV(
Expand Down
7 changes: 6 additions & 1 deletion test/functional/rpc_updatemasternode.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,19 @@ def run_test(self):
assert_equal(result[mn6]['ownerAuthAddress'], new_mn6_owner)

# Update MN to address not owned in wallet
self.nodes[0].updatemasternode(mn1, {'ownerAddress':foreign_owner})
tx = self.nodes[0].updatemasternode(mn1, {'ownerAddress':foreign_owner})
self.nodes[0].generate(21)

# Test new owner address
result = self.nodes[0].listmasternodes()
assert_equal(result[mn1]['state'], 'ENABLED')
assert_equal(result[mn1]['ownerAuthAddress'], foreign_owner)

# Check result of getcustomtx for owner transfer
result = self.nodes[0].getcustomtx(tx)
assert_equal(result['results']['id'], mn1)
assert_equal(result['results']['ownerAddress'], foreign_owner)

if __name__ == '__main__':
TestForcedRewardAddress().main()