Closed readygo586 closed 5 years ago
import {RippleAPI} from 'ripple-lib';
let rapi;
try{
rapi = new RippleAPI({ server:`wss://s.altnet.rippletest.net:51233`});
await rapi.connect();
}catch(e){console.log(e)}
const payment = {
"source": {
"address": from,
"maxAmount": {
"value": amount.toString(),
"currency": `XRP`,
}
},
"destination": {
"address": address,
"amount": {
"value": amount.toString(),
"currency": `XRP`,
}
}
};
let prepared;
try{
prepared = await rapi.preparePayment(from, payment);
}catch(e){
console.log(e)
}
//Dont connect to node here
rapi = new RippleAPI();
const tx = await rapi.sign(prepared.txJSON, wif)
console.log(tx)
//submit the signed tx
Alternatively you can directly create and send your own txJSON
Does ripple-lib support offline sign?
Yes.
In ripple-lib's source code, I find many api.sign( ), does these function call send the txjson and secret to the network?
No. You can see the source code here: https://github.com/ripple/ripple-lib/blob/develop/src/transaction/sign.ts
It uses the local signing functionality provided by ripple-keypairs.
Thanks for the question!
@intelliot @imerkle very thanks for you clarification.
In ripple-lib's source code, I find many api.sign( ), does these function call send the txjson and secret to the network? if yes, is there any method to sign locally?