Skip to content

Commit

Permalink
Resolve getcustomtx call with updatemasternode on owner transfer (#1672)
Browse files Browse the repository at this point in the history
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
Bushstar and prasannavl authored Dec 27, 2022
1 parent 8794256 commit acceaea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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()

0 comments on commit acceaea

Please sign in to comment.