Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions gitlab/deploy-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ publish_snapshot_to_maven:
- job: build_kotlin
artifacts: true
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- if: '$CI_COMMIT_BRANCH'
when: manual
script:
- cd libs/gl-sdk-android
Expand All @@ -64,6 +68,12 @@ publish_snapshot_to_maven:
- NEXT_PATCH=$((PATCH + 1))
- NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
- SNAPSHOT_VERSION="${NEXT_VERSION}-SNAPSHOT"
- echo "Publishing snapshot version ${SNAPSHOT_VERSION} (base=${BASE_VERSION})"
- ./gradlew -PlibraryVersion=${SNAPSHOT_VERSION} publish --no-daemon
- SNAPSHOT_VERSION_COMMIT="${NEXT_VERSION}-${GIT_COMMIT}-SNAPSHOT"
- |
if [ "$CI_COMMIT_BRANCH" = "master" ]; then
echo "Publishing snapshot versions ${SNAPSHOT_VERSION}"
./gradlew -PlibraryVersion=${SNAPSHOT_VERSION} publish --no-daemon
fi
echo "Publishing snapshot version ${SNAPSHOT_VERSION_COMMIT}"
./gradlew -PlibraryVersion=${SNAPSHOT_VERSION_COMMIT} publish --no-daemon
allow_failure: true
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ class AuthApiTest {
@Test(expected = Exception.PhraseCorrupted::class)
fun register_bad_mnemonic() {
val config = Config()
register("not a valid mnemonic", null, config)
NodeBuilder(config).register("not a valid mnemonic", null)
}

@Test(expected = Exception.PhraseCorrupted::class)
fun recover_bad_mnemonic() {
val config = Config()
recover("not a valid mnemonic", config)
NodeBuilder(config).recover("not a valid mnemonic")
}

@Test(expected = Exception.PhraseCorrupted::class)
fun connect_bad_mnemonic() {
val config = Config()
connect("not a valid mnemonic", "fake-creds".toByteArray(), config)
NodeBuilder(config).connect("fake-creds".toByteArray(), "not a valid mnemonic")
}

// ============================================================
Expand All @@ -88,7 +88,7 @@ class AuthApiTest {
@Test
fun register_or_recover_returns_node() {
val config = Config()
val node = registerOrRecover(testMnemonic, null, config)
val node = NodeBuilder(config).registerOrRecover(testMnemonic, null)
assertNotNull(node)
node.use { n ->
val creds = n.credentials()
Expand All @@ -104,12 +104,12 @@ class AuthApiTest {

// Register or recover to get credentials
val savedCreds: ByteArray
registerOrRecover(testMnemonic, null, config).use { node ->
NodeBuilder(config).registerOrRecover(testMnemonic, null).use { node ->
savedCreds = node.credentials()
}

// Connect with the saved credentials
connect(testMnemonic, savedCreds, config).use { node ->
NodeBuilder(config).connect(savedCreds, testMnemonic).use { node ->
assertNotNull(node)
val reconnectedCreds = node.credentials()
assertTrue("Reconnected credentials should not be empty", reconnectedCreds.isNotEmpty())
Expand All @@ -124,7 +124,7 @@ class AuthApiTest {
fun disconnect_is_idempotent() {
val config = Config()

val node = registerOrRecover(testMnemonic, null, config)
val node = NodeBuilder(config).registerOrRecover(testMnemonic, null)
// First disconnect
node.disconnect()
// Second disconnect should not throw
Expand All @@ -139,7 +139,7 @@ class AuthApiTest {
@Test
fun register_or_recover_and_create_invoice() {
val config = Config()
registerOrRecover(testMnemonic, null, config).use { node ->
NodeBuilder(config).registerOrRecover(testMnemonic, null).use { node ->
val addrResponse = node.onchainReceive()
assertNotNull(addrResponse)
println("Deposit funds to: $addrResponse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ListPaymentTest {
@Test
fun created_invoice_appears_in_list_invoices() {
val config = Config()
registerOrRecover(testMnemonic, null, config).use { node ->
NodeBuilder(config).registerOrRecover(testMnemonic, null).use { node ->
val label = Uuid.random().toString()
node.receive(label = label, description = "Coffee", amountMsat = 10_000_000uL)

Expand All @@ -84,7 +84,7 @@ class ListPaymentTest {
@Test
fun unpaid_invoices_excluded() {
val config = Config()
registerOrRecover(testMnemonic, null, config).use { node ->
NodeBuilder(config).registerOrRecover(testMnemonic, null).use { node ->
val label = Uuid.random().toString()
node.receive(label = label, description = "Tea", amountMsat = 5_000_000uL)

Expand All @@ -107,7 +107,7 @@ class ListPaymentTest {
@Test
fun type_filter_received_only() {
val config = Config()
registerOrRecover(testMnemonic, null, config).use { node ->
NodeBuilder(config).registerOrRecover(testMnemonic, null).use { node ->
val label = Uuid.random().toString()
node.receive(label = label, description = "Tea", amountMsat = 5_000_000uL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LoggingTest {
val config = Config()
val mnemonic = "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong"
try {
registerOrRecover(mnemonic, null, config)
NodeBuilder(config).registerOrRecover(mnemonic, null)
} catch (_: Exception) {
// May fail on network / credentials — we only care that logs flowed.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NodeOperationsTest {
fun test_onchain_receive_and_invoice() {
val config = Config()

val node = registerOrRecover(mnemonic = testMnemonic, inviteCode = null, config = config)
val node = NodeBuilder(config).registerOrRecover(testMnemonic, null)

node.use { n ->
// Get an on-chain address to fund the node
Expand All @@ -47,7 +47,7 @@ class NodeOperationsTest {
@Test
fun test_node_state_returns_valid_snapshot() {
val config = Config()
val node = registerOrRecover(mnemonic = testMnemonic, inviteCode = null, config = config)
val node = NodeBuilder(config).registerOrRecover(testMnemonic, null)
node.use { n ->
val state = n.nodeState()
assertTrue(state.id.isNotEmpty())
Expand Down
4 changes: 3 additions & 1 deletion libs/gl-sdk-cli/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ pub enum Command {

pub fn handle(cmd: Command, data_dir: &DataDir) -> Result<()> {
let creds = util::read_credentials(data_dir)?;
let node = glsdk::Node::new(&creds).map_err(|e| Error::Other(e.to_string()))?;
// CLI wraps an externally-running signer (the gl-client signer
// launched out-of-process); the SDK Node is signerless.
let node = glsdk::Node::signerless(creds).map_err(|e| Error::Other(e.to_string()))?;

match cmd {
Command::GetInfo => get_info(&node),
Expand Down
3 changes: 0 additions & 3 deletions libs/gl-sdk-cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ pub enum NodeEventOutput {
label: String,
amount_msat: u64,
},
#[serde(rename = "unknown")]
Unknown,
}

impl From<glsdk::NodeEvent> for NodeEventOutput {
Expand All @@ -337,7 +335,6 @@ impl From<glsdk::NodeEvent> for NodeEventOutput {
label: details.label,
amount_msat: details.amount_msat,
},
glsdk::NodeEvent::Unknown => NodeEventOutput::Unknown,
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions libs/gl-sdk-napi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,20 @@ impl NodeEventStream {

#[napi]
impl Node {
/// Create a new node connection
/// Create a signerless node from credentials.
///
/// No SDK-side signer runs — signing happens elsewhere (paired
/// device, hardware signer, the CLN node's local signer). For
/// the SDK-as-signer model, use the `register` / `recover` /
/// `connect` free functions with a mnemonic.
///
/// # Arguments
/// * `credentials` - Device credentials
#[napi(constructor)]
pub fn new(credentials: &Credentials) -> Result<Self> {
// Constructor stays sync — connection is established lazily
// Connection is established lazily on first RPC.
let inner =
GlNode::new(&credentials.inner).map_err(|e| Error::from_reason(e.to_string()))?;
GlNode::signerless(credentials.inner.clone()).map_err(|e| Error::from_reason(e.to_string()))?;

Ok(Self { inner: std::sync::Arc::new(inner) })
}
Expand Down Expand Up @@ -866,10 +871,6 @@ fn napi_node_event_from_gl(event: GlNodeEvent) -> NodeEvent {
amount_msat: details.amount_msat as i64,
}),
},
GlNodeEvent::Unknown => NodeEvent {
event_type: "unknown".to_string(),
invoice_paid: None,
},
}
}

Expand Down
Loading
Loading