Jump to content
Astilen

Multisigning offline with ripple lib

Recommended Posts

I have been doing all sorts of offline transactions, but I haven't managed to do any multisigning yet. Any help is so much appreciated!

The following script is a SignerListSet, which creates a blob that will be later copied in a submit script:

'use strict';
const {RippleAPI} = require('ripple-lib');
const api = new RippleAPI();

const txJSON = '{"Flags": 0,"TransactionType": "SignerListSet","Account": "rnNP5r6SR26WTAYRjpinKHqSeYtYhA9ig8","LastLedgerSequence":26283561,"Fee": "500","Sequence":36,"SignerQuorum": 2,"SignerEntries":[{"SignerEntry":{"Account": "rf71e*****************************","SignerWeight": 1}},{"SignerEntry": {"Account":"rKoAh*****************************","SignerWeight":1}}]}';

const secret = 's*****************************';

var r = api.sign(txJSON, secret);
console.log("signed transaction: ", r.signedTransaction);
console.log("transaction id", r.id);

I then copied the blob into a submit script, which uses a server that I am sure it has multisigning enabled:
const api = new RippleAPI({
  server: 'wss://s1.ripple.com'
});

After submitting, the console looks like this:
{ resultCode: 'terQUEUED',
  resultMessage: 'Held until escalated fee drops.' }
disconnected, code: 1000

rippleok.com shows my Sequence number increased, but the Transactions History does not list anything. Notice how 33 is followed by 35, the 34 is the SignerListSet and it is missing:
multisignProblem1.png

 

At charts.ripple.com/#/graph the transaction apprears as empty, and when I hover over it says "undefined":
multisignProblem2.png

If I make an order without signing from the accounts in the signer list, it successfully goes through. 

Any insight as to what I'm doing wrong?

Edited by Astilen

Share this post


Link to post
Share on other sites

I was told that multisigning might be successfully enabled despite the fact that the tools I mentioned dont show it. Also, the master key is still supposed to create transactions until disabled. However, in order to test that I can indeed form multisign transactions, I created 2 offline orders with the following script:

'use strict';
const {RippleAPI} = require('ripple-lib');
const api = new RippleAPI();

const txJSON = '{"TransactionType":"OfferCreate","Account":"rnNP5r6SR26WTAYRjpinKHqSeYtYhA9ig8","TakerGets":"100000","TakerPays":{"currency":"USD","issuer":"rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq","value":"0.000657"},"Flags":2147549184,"LastLedgerSequence":26304999,"Fee":"200","SigningPubKey": "","Sequence":37}';
const secret = 's*****************************';

var r = api.sign(txJSON, secret);

console.log("signed transaction: ", r.signedTransaction);
console.log("transaction id", r.id);


After running the script once and noting the created blob, I changed the key to the second account in the signers list and run it again to get a second blob. I then used the "combine" script below:
const signedTransactions = [ "12000722800100002400000025201B01916...*****(...a lot more stars)*******...B3C4282E352A",
"12000722800100002400000025201B019161...********(...a lot more stars)*****...B0149CB3C4282E352A" ];
return api.combine(signedTransactions);


The console now looks like this:
connected
[ValidationError(txJSON is not the same for all signedTransactions)]


I dont get it, I only changed the secrets, the txJSON remained the same. Please shed some light!

Share this post


Link to post
Share on other sites
On 12/16/2016 at 1:14 PM, Astilen said:

rippleok.com shows my Sequence number increased, but the Transactions History does not list anything. Notice how 33 is followed by 35, the 34 is the SignerListSet and it is missing:

At charts.ripple.com/#/graph the transaction apprears as empty, and when I hover over it says "undefined":

many tools out there not yet updated to display the SignerListSet transactions.

can try my wallet if you like:  http://ripplerm.github.io/ripple-wallet/

 

10 hours ago, Astilen said:

const txJSON = '{"TransactionType":"OfferCreate","Account":"rnNP5r6SR26WTAYRjpinKHqSeYtYhA9ig8","TakerGets":"100000","TakerPays":{"currency":"USD","issuer":"rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq","value":"0.000657"},"Flags":2147549184,"LastLedgerSequence":26304999,"Fee":"200","SigningPubKey": "","Sequence":37}';
const secret = 's*****************************';

var r = api.sign(txJSON, secret);

 

for multisign txn signing, should include "signAs" options. https://ripple.com/build/rippleapi/#sign

try something like follow:

Quote

var signer1 = "r........";   //address for signing.

var signer2 = "r2.....";  //another address for signing.

 

options = { signAs: signer1}

var signed1 = api.sign(txJSON, secret, options);

 

options = {signAs: signer2}

var signed2 = api.sign(txJSON, secret2, options);

 

var tx = api.combine([signed1, signed2]);

 

 

 

Edited by ripplerm
update

Share this post


Link to post
Share on other sites

The ripple wallet is awesome, I finally know that I successfully set up my signer list! Thank you so much!

However, I am still struggling with the multisigned transaction. Note that the script must not contain both signer secrets, each signer must not know the others key.

The signers should only share their blobs, and then combine them.. First I tried this with each signer :

const options = '{"signAs": "rKoAh9*****************************"}';
var r = api.sign(txJSON, secret, options);

 After combining I got the same ValidationError. Then I tried:

const signAs = 'rKoAh9*****************************"}';
var r = api.sign(txJSON, secret, signAs);

I got the same ValidationError. I tried to set up the signAs option differently but I got compilation errors, I'm not much of a programmer. 

Edited by Astilen

Share this post


Link to post
Share on other sites

Does anyone use the signAs option to sign with ripple lib? 

I tried this but I get compilation error at the dot (options.signAs):

const options.signAs = 'rKoAh9oV**************************';

Share this post


Link to post
Share on other sites
On 12/18/2016 at 11:14 AM, Astilen said:

const options = '{"signAs": "rKoAh9*****************************"}';

var r = api.sign(txJSON, secret, options);

the above should be the correct way...  for the options normally should just use object instead of string;

 

there's a tiny mistake in my previous post... correction here:

On 12/18/2016 at 7:10 PM, ripplerm said:

options = { signAs: signer1}

var signed1 = api.sign(txJSON, secret, options);

options = {signAs: signer2}

var signed2 = api.sign(txJSON, secret2, options);

var tx = api.combine([signed1, signed2]);

var tx = api.combine([signed1.signedTransaction, signed2.signedTransaction]);

 

Edited by ripplerm
correction

Share this post


Link to post
Share on other sites
12 hours ago, ripplerm said:

the above should be the correct way...  for the options normally should just use object instead of string;

Combining the signedTransactions still gives me this error: [ValidationError(txJSON is not the same for all signedTransactions)]

I am completely lost!

Share this post


Link to post
Share on other sites
On 12/21/2016 at 10:16 AM, Astilen said:

Combining the signedTransactions still gives me this error: [ValidationError(txJSON is not the same for all signedTransactions)]

the options should be an object instead of string.

try remove your quotes.

Share this post


Link to post
Share on other sites

Hello, 

I have a similar situation, in my case I already have an account ready for multi-signature and the following code:

 

return api.preparePayment(sourceAddress, payment, instructions).then(
                    function(prepared) {
			var tempJSON = JSON.parse(prepared.txJSON);
			tempJSON["SigningPubKey"] = "";
			prepared.txJSON =JSON.stringify(tempJSON);
                        console.log("prepared.txJSON = ", JSON.stringify(prepared.txJSON, null, 2));

                        var signResult1 = api.sign(prepared.txJSON, signerSecret1, {"signAs": signerAddress1});
                        var signResult2 = api.sign(prepared.txJSON, signerSecret2, {"signAs": signerAddress2});
                        var signResult3 = api.sign(prepared.txJSON, signerSecret3, {"signAs": signerAddress2});
                        var combinedResult = api.combine([signResult1.signedTransaction, signResult2.signedTransaction, signResult3.signedTransaction]);
                        return api.submit(combinedResult.signedTransaction).then(function(result) {
                            console.log('Transaction submitted');
                            console.log("result = ", result);
                            startTime = Date.now();
                            return combinedResult.id;
                        }).then(function(txId) {
                            // Constantly check for the transaction to
                            // be settled in a validated ledger
                            console.log("txId = ", txId);
                            const getTxOptions = {
                                minLedgerVersion: ledgerVersion,
                                maxLedgerVersion: ledgerVersion + 15
                            };
                            return verifyTransaction(txId, getTxOptions);
                        });

                    },
                    function (error) {
                        console.log("prepareOrder error = ", error);
                    }

                );

The prepared.txJSON is

prepared.txJSON =  "{\"TransactionType\":\"Payment\",\"Account\":\"rK8v4Jco5um5T8ztQmZCVTZxfc9cN7PiFk\",\"Destination\":\"rE5BLm7kZZKGmxQE5tRRur69edjYLpT59a\",\"Amount\":{\"currency\":\"MXN\",\"issuer\":\"rJ4izp2BKK561e9mGwyznQYMjuDckosmpL\",\"value\":\"1.0\"},\"Flags\":2147483648,\"SendMax\":{\"currency\":\"MXN\",\"issuer\":\"rJ4izp2BKK561e9mGwyznQYMjuDckosmpL\",\"value\":\"1.1\"},\"LastLedgerSequence\":1425779,\"Fee\":\"34560\",\"Sequence\":26,\"SigningPubKey\":\"\"}"

payment and instructions used to prepare the payment are, destinationAddress and sourceAddress are modified before payment is passed to prepareTransaction:


payment={
  "destination": {
    "amount": {
      "currency": "MXN",
      "value": "1.0",
      "counterparty": "rJ4izp2BKK561e9mGwyznQYMjuDckosmpL"
    },
    "address": "destinationAddress"
  },
  "source": {
    "maxAmount": {
      "currency": "MXN",
      "value": "1.1",
      "counterparty": "rJ4izp2BKK561e9mGwyznQYMjuDckosmpL"
    },
    "address": "sourceAddress"
  }
};

instructions = {maxLedgerVersion: ledgerVersion + 15, signersCount:3};

after the code executes, I get the error [RippledError(invalidTransaction)], however, a similar transaction is successful using the rippled instructions. Any idea why?.

Edited by userzc

Share this post


Link to post
Share on other sites

Hey, 

Could we validate offline a multi-signature process ? Does ripple has the concept of Multisignature address ? Because with the Ripple address that initiate the transaction, after having created a list of signer and submitted it I can still send transaction without the signer right ? 

What does the weight/quorum system is currently used ?

Thanks

Share this post


Link to post
Share on other sites

Not to encourage bumping ancient threads, but...

4 hours ago, Jeamick said:

Could we validate offline a multi-signature process ?

I don't know what this means.

4 hours ago, Jeamick said:

What does the weight/quorum system is currently used ?

https://developers.ripple.com/multi-signing.html

Any given address can have up to 1 SignerList, which contains 1 to 8 signers. Each signer has a weight from 1 to 65535. The list also has a quorum with a value from 1 to 4294967295. The sum value of the signers' weights must be equal or higher than the list's quorum.

 

4 hours ago, Jeamick said:

Does ripple has the concept of Multisignature address ? Because with the Ripple address that initiate the transaction, after having created a list of signer and submitted it I can still send transaction without the signer right ? 

If you disable the master key, then you'll only be able to use the multi-signing list (if you've set one) and regular key (if you've set one). See the "Cryptographic Keys" article for more info.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...