Open y0ke opened 6 years ago
I use these code and meet a error same with you.
import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import AppXrp from "@ledgerhq/hw-app-xrp";
const binaryEncode = require('ripple-binary-codec');
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'});
const multiSignAddress = "rNxyGCYnypq5vELR2TdJNwrdA4PwTsN5sZ";
async function multiSign() {
const transport = await Transport.create();
const xrpApp = new AppXrp(transport);
let addr1 = await xrpApp.getAddress("44'/144'/0'/0/0");
let addr2 = await xrpApp.getAddress("44'/144'/0'/0/1");
console.log('addr1 ', addr1);
console.log('addr2 ', addr2);
let payment = {
Account: "rNxyGCYnypq5vELR2TdJNwrdA4PwTsN5sZ",
Amount: "1000000",
Destination: "r4Z7imQR1gKSKmi4pmmwd8CJP8cvs7nxTP",
Fee: "36",
Sequence: "9",
TransactionType: "Payment",
SigningPubKey: ""
};
// payment.SigningPubKey = addr1.publicKey.toUpperCase();
let serializedTx = binaryEncode.encodeForMultisigning(payment, addr1.address);
console.log("encode for multi sign", serializedTx);
let signature1 = await xrpApp.signTransaction("44'/144'/0'/0/0", serializedTx);
let signer1 = {
Signer: {
Account: addr1.address,
SigningPubKey: addr1.publicKey.toUpperCase(),
TxnSignature: signature1.toUpperCase()
}
};
// payment.SigningPubKey = addr2.publicKey.toUpperCase();
let signature2 = await xrpApp.signTransaction("44'/144'/0'/0/1", serializedTx);
let signer2 = {
Signer: {
Account: addr2.address,
SigningPubKey: addr2.publicKey.toUpperCase(),
TxnSignature: signature2.toUpperCase()
}
};
payment.SigningPubKey = "";
payment.Signers = [signer1, signer2];
console.log(JSON.stringify(payment));
let signedSerialized = binaryEncode.encode(payment);
console.log(signedSerialized);
}
multiSign();
And use following code to sign tx but got a invalid signatures
import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import AppXrp from "@ledgerhq/hw-app-xrp";
const binaryEncode = require('ripple-binary-codec');
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'});
const multiSignAddress = "rNxyGCYnypq5vELR2TdJNwrdA4PwTsN5sZ";
async function multiSign() {
const transport = await Transport.create();
const xrpApp = new AppXrp(transport);
let addr1 = await xrpApp.getAddress("44'/144'/0'/0/0");
let addr2 = await xrpApp.getAddress("44'/144'/0'/0/1");
console.log('addr1 ', addr1);
console.log('addr2 ', addr2);
let payment = {
Account: "rNxyGCYnypq5vELR2TdJNwrdA4PwTsN5sZ",
Amount: "1000000",
Destination: "r4Z7imQR1gKSKmi4pmmwd8CJP8cvs7nxTP",
Fee: "36",
Sequence: "9",
TransactionType: "Payment",
};
// payment.SigningPubKey = addr1.publicKey.toUpperCase();
let serializedTx = binaryEncode.encode(payment);
console.log("encode for multi sign", serializedTx);
let signature1 = await xrpApp.signTransaction("44'/144'/0'/0/0", serializedTx);
let signer1 = {
Signer: {
Account: addr1.address,
SigningPubKey: addr1.publicKey.toUpperCase(),
TxnSignature: signature1.toUpperCase()
}
};
// payment.SigningPubKey = addr2.publicKey.toUpperCase();
let signature2 = await xrpApp.signTransaction("44'/144'/0'/0/1", serializedTx);
let signer2 = {
Signer: {
Account: addr2.address,
SigningPubKey: addr2.publicKey.toUpperCase(),
TxnSignature: signature2.toUpperCase()
}
};
payment.SigningPubKey = "";
payment.Signers = [signer1, signer2];
console.log(JSON.stringify(payment));
let signedSerialized = binaryEncode.encode(payment);
console.log(signedSerialized);
}
multiSign();
I post the signedSerialized, and response is fails local checks: Invalid signature on account rxxxxxxxx...
Hi @y0ke @qiluge,
Is this issue resolved since I am getting the same error ie. : fails local checks: Invalid signature on account rxxxxxxxx...
Thanks
I'm trying to sign a simple multisign transaction though, It seems that XRP's
signTransaction
throws an error if a given raw tx'sSigningPubKey
is empty.Is there any way to sign a multisign transaction with ledgerjs? Any advice or suggestions will be greatly appreciated