I need to build transaction on machine with internet via go sdk and then sign it on offline machine
-
I note in the godocs that there's no method to get the Base64 XDR from an unsigned transaction (TransactionBuilder). godoc.org/github.com/stellar/go/build#TransactionBuilder . If there was, you could follow the examples from stellar.org/developers/go/reference/examples.html.– SynessoCommented Aug 2, 2018 at 9:51
-
I've added a support ticket, in case it is missing functionality. github.com/stellar/go/issues/570– SynessoCommented Aug 2, 2018 at 10:18
-
@Synesso Thank you for ticket I just want a similar way to sign offline transaction like in bitcoin or ethereum blockchains where we can create transaction, decompose hash and get txId then sign it with offline wallet and send to blockchain with online wallet– frankegoesdownCommented Aug 2, 2018 at 10:35
3 Answers
This is how i convert the XDR before the initial signature.
trustTx, err := build.Transaction(
build.SourceAccount{recipient.Address()},
build.AutoSequence{SequenceProvider: horizon.DefaultTestNetClient},
build.TestNetwork,
build.Trust(Asset.Code, Asset.Issuer, build.Limit(cd.Limit)),
)
var result build.TransactionEnvelopeBuilder
err := result.Mutate(trustTx)
if err != nil {
log.Fatal(err)
}
trustTxeB64, err := result.Base64()
To sign in client side offline
var txe xdr.TransactionEnvelope
err = xdr.SafeUnmarshalBase64(trustTxeB64, &txe)
if err != nil {
log.Fatal(err)
}
b := &build.TransactionEnvelopeBuilder{E: &txe}
b.Init()
err = b.MutateTX(build.TestNetwork)
if err != nil {
log.Fatal(err)
}
err = b.Mutate(build.Sign{cd.Signerkey})
if err != nil {
log.Fatal(err)
}
newEnv, err := xdr.MarshalBase64(b.E)
if err != nil {
log.Fatal(err)
}
to submit that to an online node
resp, err := horizon.DefaultTestNetClient.SubmitTransaction(newEnv)
-
Thx for answer but how do you sign it on offline stellar node and then send to block chain with online node?? Commented Sep 6, 2018 at 7:26
-
You can create a client side application where user can import their privatekey and sign the XDR in client side and convert it as a signed XDR. then they can submit that through horizon. Commented Sep 6, 2018 at 7:33
-
I update my answer hope now you can sing this in offline and submit online Commented Sep 6, 2018 at 8:29
There is no need for the internet to build the transaction. Only you need to network to submit the transaction to horizon. To build the transaction you can use go SDK and need to export as base64. at the moment as i know we can get the base64 XDR after signed only. So if you want to use multisign then you can sign and build the transaction in go SDK and send the XDR to others and get their signs as well. They can sign through laboratory or even you can provide any client interface where you use one of the stellar SDK and sign and return the XDR. To make the transaction succeed you need to have the internet connection and you need to submit that to stellar horizon.
-
I suspect the use-case is that the transaction is formed from a request coming over the network, saved to disk and signed from cold storage. It's not necessarily multi-sig.– SynessoCommented Aug 2, 2018 at 10:16
-
in that case the request can build but to retrieve as base64 we need to sign in go SDK. other wise i dont think there is any way in GO. But its possible in laboratory Commented Aug 2, 2018 at 10:22
While not quite the intention of this question, this functionality is currently fully featured and available in the JavaScript SDK.