-
Notifications
You must be signed in to change notification settings - Fork 0
core lightning #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4c587b4
add payer_note and external_id
ntheile 0207cbf
cln get_info
ntheile bb0632c
cln pay offer
ntheile e7343aa
fix types
ntheile 61a4378
cln nodejs
ntheile b370cd6
cln listTransactions
ntheile f947c9f
fix cln lib export
ntheile 7fa7f51
update for ios
ntheile e830c45
cln bolt11 create_invoice
ntheile 338519a
cln decode, paycode, get_offer, list_offer
ntheile 6964e1b
..Default::default()
ntheile 32a0cdd
uniffi.toml
ntheile 33adcfc
custom type
ntheile bacbaf4
.
ntheile 10c69d3
.
ntheile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,101 @@ | ||
import { PhoenixdNode, InvoiceType, Db } from "./index.js"; | ||
import { PhoenixdNode, ClnNode, InvoiceType } from "./index.js"; | ||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
|
||
const config = { | ||
url: process.env.PHOENIXD_URL, | ||
password: process.env.PHOENIXD_PASSWORD, | ||
test_hash: process.env.PHOENIXD_TEST_PAYMENT_HASH, | ||
}; | ||
const node = new PhoenixdNode(config); | ||
const info = await node.getInfo(); | ||
console.log("Node info:", info); | ||
|
||
const configRes = await node.getConfig(); | ||
console.log("Config:", configRes.url); | ||
|
||
const invoice = await node.makeInvoice({ | ||
amountMsats: 1000, | ||
description: "test invoice", | ||
invoiceType: InvoiceType.Bolt11, | ||
}); | ||
console.log("Invoice:", invoice); | ||
|
||
const lookupInvoice = await node.lookupInvoice(process.env.PHOENIXD_TEST_PAYMENT_HASH); | ||
console.log("lookupInvoice:", lookupInvoice); | ||
|
||
const payOffer = await node.payOffer(process.env.TEST_OFFER, 3000, 'payment from lni nodejs'); | ||
console.log("payOffer:", payOffer); | ||
|
||
const txns = await node.listTransactions({ | ||
from: 0, | ||
until: 0, | ||
limit: 10, | ||
offset: 0, | ||
unpaid: false, | ||
invoiceType: "all", | ||
}); | ||
console.log("Transactions:", txns); | ||
|
||
// const db = new Db("test.json"); | ||
// db.writePayment({ | ||
// paymentId: "1", | ||
// circId: "1", | ||
// round: 1, | ||
// relayFingerprint: "1", | ||
// updatedAt: 1, | ||
// amountMsats: 1, | ||
// amount_msats: 1000, | ||
// }); | ||
async function phoenixd() { | ||
const config = { | ||
url: process.env.PHOENIXD_URL, | ||
password: process.env.PHOENIXD_PASSWORD, | ||
test_hash: process.env.PHOENIXD_TEST_PAYMENT_HASH, | ||
}; | ||
const node = new PhoenixdNode(config); | ||
const info = await node.getInfo(); | ||
console.log("Node info:", info); | ||
|
||
const configRes = await node.getConfig(); | ||
console.log("Config:", configRes.url); | ||
|
||
const invoice = await node.createInvoice({ | ||
amountMsats: 1000, | ||
description: "test invoice", | ||
invoiceType: InvoiceType.Bolt11, | ||
}); | ||
console.log("Invoice:", invoice); | ||
|
||
const lookupInvoice = await node.lookupInvoice( | ||
process.env.PHOENIXD_TEST_PAYMENT_HASH | ||
); | ||
console.log("lookupInvoice:", lookupInvoice); | ||
|
||
const payOffer = await node.payOffer( | ||
process.env.TEST_RECEIVER_OFFER, | ||
3000, | ||
"payment from lni nodejs" | ||
); | ||
console.log("payOffer:", payOffer); | ||
|
||
const txns = await node.listTransactions({ | ||
from: 0, | ||
limit: 10, | ||
}); | ||
console.log("Transactions:", txns); | ||
|
||
const offer = await node.getOffer(); | ||
console.log("Get Offer:", offer); | ||
} | ||
|
||
async function cln() { | ||
const config = { | ||
url: process.env.CLN_URL, | ||
rune: process.env.CLN_RUNE, | ||
}; | ||
const node = new ClnNode(config); | ||
const info = await node.getInfo(); | ||
console.log("Node info:", info); | ||
|
||
// const configRes = await node.getConfig(); | ||
// console.log("Config:", configRes.url); | ||
|
||
const invoice = await node.createInvoice({ | ||
amountMsats: 1000, | ||
description: "test invoice", | ||
invoiceType: InvoiceType.Bolt11, | ||
}); | ||
console.log("Invoice:", invoice); | ||
|
||
const bolt11Invoice = await node.createInvoice({ | ||
amountMsats: 3000, | ||
description: "test invoice", | ||
invoiceType: InvoiceType.Bolt11, | ||
}); | ||
console.log("CLN bolt11 Invoice:", bolt11Invoice); | ||
|
||
const offer = await node.getOffer(); | ||
console.log("CLN Bolt12 Offer:", offer); | ||
|
||
const lookupInvoice = await node.lookupInvoice( | ||
process.env.CLN_TEST_PAYMENT_HASH | ||
); | ||
console.log("lookupInvoice:", lookupInvoice); | ||
|
||
// TODO not working (cln <=> phoneixd issue?) | ||
// const payOffer = await node.payOffer( | ||
// process.env.TEST_RECEIVER_OFFER, | ||
// 3000, | ||
// "payment from lni nodejs" | ||
// ); | ||
// console.log("payOffer:", payOffer); | ||
|
||
const txns = await node.listTransactions({ | ||
from: 0, | ||
limit: 10, | ||
}); | ||
console.log("Transactions:", txns); | ||
} | ||
|
||
async function main() { | ||
phoenixd(); | ||
cln(); | ||
} | ||
|
||
main(); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.