Last active
December 28, 2020 20:26
-
-
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
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
{ | |
"dest": "{{lightning-dest-pubkey-base64}}", | |
"amt": "{{lightning-payment-amount}}", | |
"timeout_seconds": 60, | |
"payment_hash": "{{lightning-payment-hash}}", | |
"dest_custom_records": { | |
"5482373484": "{{lightning-preimage}}" | |
} | |
} |
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
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