Created
November 3, 2020 21:52
-
-
Save ysv/c5191f243b4357d1a5e761e7dafd5d4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RippleAPI = require('ripple-lib').RippleAPI; | |
const api = new RippleAPI({ | |
server: 'wss://testnet.xrpl-labs.com' // Public rippled server | |
}); | |
api.connect().then(() => { | |
/* begin custom code ------------------------------------ */ | |
const wallet_hot = 'r4fCw4QyjNdXQF1rYUo71EbZ13Gq8TwNuS'; | |
a_acc = { | |
address: 'rsUgwE4czke7cRHUJuJEK56ZsoZyRvTDBn', | |
secret: 'ssdNpZMTyRiydk1czPtsGvq7Dc13w' | |
} | |
b1_acc = { | |
address: 'rB9SSWDvwCPvE9Q2axSH7YWVYLMbEzpPd2', | |
secret: 'shu5WFbh3siTu25KKpvynauzLjntE' | |
} | |
b2_acc = { | |
address: 'rDfug7fMs3CxXzZ1eTsxxSRynYjkJjYSip', | |
secret: 'snC8TxEJPTqEa2n1LG7BwUMHwY8AT' | |
} | |
tx = { | |
TransactionType: "TrustSet", | |
Account: wallet_hot, | |
LimitAmount: { | |
currency: "786E617375733838313630723130313430303031", | |
issuer: "rarRYh3WZCkSKWWpJiq1kxfZwBuZLMgazm", | |
value: "10000000" | |
}, | |
Flags: "0x00020000", | |
Fee: "60" | |
} | |
api.prepareTransaction(tx).then(prepared => { | |
console.log(prepared); | |
a_sign = api.sign(prepared.txJSON, a_acc.secret, {'signAs': a_acc.address}).signedTransaction; | |
b1_sign = api.sign(prepared.txJSON, b1_acc.secret, {'signAs': b1_acc.address}).signedTransaction; | |
b2_sign = api.sign(prepared.txJSON, b2_acc.secret, {'signAs': b2_acc.address}).signedTransaction; | |
console.log(a_sign); | |
console.log(b1_sign); | |
console.log(b2_sign); | |
let combinedTx = api.combine([a_sign, b1_sign, b2_sign]); | |
console.log(combinedTx) | |
// NOTE: On this step it may brake so I used to copy blob and submit using https://test.bithomp.com/submit/ | |
api.submit(combinedTx.signedTransaction).then(response => { | |
console.log("should be ok now"); | |
console.log(response.tx_json.hash); | |
return api.disconnect(); | |
}).catch(console.error); | |
}); | |
return api.getAccountInfo(wallet_hot); | |
}).then(info => { | |
console.log(info); | |
console.log('getAccountInfo done'); | |
/* end custom code -------------------------------------- */ | |
}).then(() => { | |
return api.disconnect(); | |
}).then(() => { | |
console.log('done and disconnected.'); | |
}).catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment