Multisigi transaction from Java to Javascript - General - Algorand
Multisigi transaction from Java to Javascript
post by Mister_Enzo on Sep 5, 2020
Hi there,
I have a client A that uses the JavaSDK to produce a multisig address composed by the account A and B and a signed transaction. The transaction is signed by A only.
A wants to send the transaction to the backend B, so B can sign it and send to the blockchain.
A sends to B this JSON:
{"multiSigAccount":{
"publicKeys":[
"wFJi8oEISKHen0LDeEk+yXD3zHQNeultuTF+xVbnQzw=",
"dRQsIsSYbCE4YhxNGMFV0ykS1WBvrl5O7vX+3SvjDy0="
],
"threshold":2,
"version":1
},
"signedTransaction":{
"msig":{
"subsig":[
{"pk":"wFJi8oEISKHen0LDeEk+yXD3zHQNeultuTF+xVbnQzw=",
"s":"jNxed0mD+7jPAP7sGBIEq0hBoVk5RJ8+l9GxMypISMI+dKwWeiGGNse2vsCBjrqR860sfJsuC4py23dxDdUFBg=="},
{"pk":"dRQsIsSYbCE4YhxNGMFV0ykS1WBvrl5O7vX+3SvjDy0=",
"s":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="}
],
"thr":2,
"v":1
},
"txn":{
"close":"NcSelNBbzNvQC5PSu0I8yJvwTjdPxlSerO8UI+5T6Ic=",
"fee":1000,
"fv":9061117,
"gen":"testnet-v1.0",
"gh":"SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
"lv":9062117,
"note":"2VB7ImRpYWdub3Npc0tleXMiOlsiWUJKR0Y0VUJCQkVLRFhVN0lMQlhRU0o2WkZZUFBURFVCjVPUzNOWkdGN01LVlhISU02RUxNWUxZVSJdfQ==",
"rcv":"NcSelNBbzNvQC5PSu0I8yJvwTjdPxlSerO8UI+5T6Ic=",
"snd":"bQFchr8rr7rK8BjoH3qAmh3oQYq1ELXjZSIfkQeLRII=",
"type":"pay"
}
}
Now B has to parse the json to reconstruct all the objects he needs to complete the transaction and send it to the blockchain.
How can i achieve this in JavascriptSDK? Is there some JSON parser that i can use? Thanks!
post by fabrice on Sep 8, 2020
It is usually simplest to serialize all the data in msgpack, instead of JSON.
You should be able to use the transaction method .bytes() ( transaction method) to serialize the transaction in Java.
Then, in JS, you can use this link, if you just need to append a multisig signature.
You can also use algosdk.decodeObj to decode the transaction, followed by this link to handle the transaction.