Skip to content

Instantly share code, notes, and snippets.

@dellagustin
Last active December 28, 2020 20:26
Show Gist options
  • Save dellagustin/c3793308b75b6b0faf134e64db7dc915 to your computer and use it in GitHub Desktop.
Save dellagustin/c3793308b75b6b0faf134e64db7dc915 to your computer and use it in GitHub Desktop.
Postman resquest to send a lightning payment using KeySend and the LND REST API
{
"dest": "{{lightning-dest-pubkey-base64}}",
"amt": "{{lightning-payment-amount}}",
"timeout_seconds": 60,
"payment_hash": "{{lightning-payment-hash}}",
"dest_custom_records": {
"5482373484": "{{lightning-preimage}}"
}
}
var encoded;
var hash;
var byteArray = new Uint8Array(32);
var dest_pubkey_hex = pm.variables.get('lightning-dest-pubkey-hex');
var dest_pubkey_base64 = Buffer.from(dest_pubkey_hex, 'hex').toString('base64');
console.log(dest_pubkey_base64)
pm.variables.set('lightning-dest-pubkey-base64', dest_pubkey_base64);
for(let i = 0; i < 32; i++) {
let randomNumber = _.random(0, 255);
byteArray[i] = randomNumber;
}
encoded = Buffer.from(byteArray).toString('base64');
hash = CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(CryptoJS.enc.Base64.parse(encoded)));
console.log(encoded);
console.log(hash);
pm.variables.set('lightning-preimage', encoded);
pm.variables.set('lightning-payment-hash', hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment