4

How would I create a transaction envelope (using Stellar Laboratory) that is partially signed so that I may finish the rest of the signatures at a later date.

1
  • Are you using one of the SDKs or an API? Commented Feb 4, 2018 at 22:03

2 Answers 2

4

From what I understand, your problem consists of 2 subproblems: how to ensure a transaction is valid at a latter point in time, and how to store and then sign a transaction with a second signature.

For the first problem, at the moment your only choice is to not submit any transaction after you created the transaction that you will submit (or alternatively, submit a predetermined number of transactions). From what I understand, in the future it will be possible to bump the sequence number of your account and this will not be an issue anymore

For the second problem, you can create and sign a transaction with the first key pair, then encode the transaction envelope and store it somewhere safe. Once you're ready to submit the transaction, you deserialize it and sign with the second account. I include sample code on how to do this with the javascript sdk.

var StellarSdk = require('stellar-sdk')
StellarSdk.Network.useTestNetwork();

// Create transaction with first signer
let keypair0 = StellarSdk.Keypair.random();
let account = new StellarSdk.Account(keypair0.publicKey(), '1234');

let tx = new StellarSdk.TransactionBuilder(account)
    .addOperation(StellarSdk.Operation.payment({
      destination: 'GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA',
      asset: StellarSdk.Asset.native(),
      amount: '100',
    }))
    .build();

tx.sign(keypair0);

let encodedEnvelope = tx.toEnvelope().toXDR('base64');

// Store encodedEnvelope somewhere.

let tx2 = new StellarSdk.Transaction(encodedEnvelope);
let keypair1 = StellarSdk.Keypair.random();
tx2.sign(keypair1)

console.log(tx2.toEnvelope().toXDR('base64'))
3

Every transaction has a Transaction Sequence Number.

Each transaction has a sequence number. Transactions follow a strict ordering rule when it comes to processing of transactions per account. For the transaction to be valid, the sequence number must be 1 greater than the sequence number stored in the source account entry

If you create a transaction envelope without signing it and submitting it to the network, you need to be positive that the account won't create any transactions until your envelope is fully submitted.

You could

var transaction = new StellarBase.TransactionBuilder(account)
        .addOperation(StellarBase.Operation.payment({
                destination: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                asset: StellarBase.Asset.native(),
                amount: "100" 
            }))
        .build();

And then wait for some event before you

transaction.sign(key);
1
  • I want to set it up as multisig (weight 2) where I sign once (weight 1) and then take that transaction envelope to another computer and sign to be able to submit the transaction. (Im trying to hide the signature key before I complete the second signature.)
    – ExMachima
    Commented Feb 4, 2018 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.