This repository was archived by the owner on May 27, 2022. It is now read-only.
forked from peerplays-network/peerplaysjs-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
This repository was archived by the owner on May 27, 2022. It is now read-only.
Unable to correctly sign transaction for witness_update #5
Copy link
Copy link
Open
Description
Hi all,
When using the lib I use my Active key to sign transactions. This works well for transfers for example.
var privKey = "5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
let pKey = PrivateKey.fromWif(privKey);
...
connect to beatrice, fetch accounts, build memo etc.
...
// Build transaction
let tr = new TransactionBuilder()
tr.add_type_operation( "transfer", {
fee: {
amount: 0,
asset_id: feeAsset.get("id")
},
from: fromAccount.get("id"),
to: toAccount.get("id"),
amount: { amount: sendAmount.amount, asset_id: sendAsset.get("id") },
memo: memo_object
} )
// Add fees, sign and broadcast
tr.set_required_fees().then(() => {
tr.add_signer(pKey, pKey.toPublicKey().toPublicKeyString());
console.log("serialized transaction:", tr.serialize());
tr.broadcast();
})
This works and the transfer is completed successfully
But when trying to broadcast an update_witness command the authority fails
var privKey = "5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
let pKey = PrivateKey.fromWif(privKey);
...
connect to beatrice, fetch account
...
// Build transaction
let tr = new TransactionBuilder()
tr.add_type_operation( "witness_update", {
fee: {
amount: 0,
asset_id: feeAsset.get("id")
},
witness: '1.6.XX',
witness_account: witnessAccount.get("id"), // Resolves correctly 1.2.XX
new_url: 'https://new.url',
new_signing_key: "TESTMyfancynewSigningKey"
} )
// Add fees, sign and broadcast
tr.set_required_fees().then(() => {
tr.add_signer(pKey, pKey.toPublicKey().toPublicKeyString());
console.log("serialized transaction:", tr.serialize());
tr.broadcast();
})
The fees are added correctly, and the transaction seems to be signed. However the Authority isn't accepted.
"broadcast_transaction_with_callback",[22,{"ref_block_num":2217,"ref_block_prefix":20
19485635,"expiration":"2018-11-06T09:42:42","operations":[[21,{"fee":{"amount":"50000","asset_id":"1.3.0"},"witness":"1.6.XX","witn
ess_account":"1.2.XX","new_url":"https://new.url","new_signing_key":"TESTFancynewsigningkey"}]],"extensions":[],"signatures":["averylongsignaturestringf670e6faa3dc34f4dd6d01916c72a73693d9bc4
f1125c036a59f57db2a28533981ff648a6fa2653259fc1e90938fdb98fbc79b4a4c"]}]]}}]}}
{ code: 1,
message: 'missing required active authority: Missing Active Authority 1.2.XX',
data:
{ code: 3030001,
name: 'tx_missing_active_auth',
message: 'missing required active authority',
stack: [ [Object], [Object], [Object], [Object], [Object], [Object] ] } }
(node:20316) UnhandledPromiseRejectionWarning: Error: missing required active authority: Missing Active Authority 1.2.XX
When I issue the same command in the cli_wallet it works, so must be something in the js-lib but I'm having trouble tracking it down. Any help appreciated.
Metadata
Metadata
Assignees
Labels
No labels