@lightsparkdev/lightspark-sdk 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-7UNNCH5S.js → chunk-VTPDR6P4.js} +1270 -342
  3. package/dist/{index-5235e43b.d.ts → index-f040db9f.d.ts} +707 -407
  4. package/dist/index.cjs +1247 -319
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +7 -7
  7. package/dist/objects/index.cjs +1180 -306
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -5
  10. package/package.json +2 -2
  11. package/src/objects/Account.ts +175 -2
  12. package/src/objects/AccountToApiTokensConnection.ts +16 -5
  13. package/src/objects/AccountToChannelsConnection.ts +9 -0
  14. package/src/objects/AccountToNodesConnection.ts +19 -5
  15. package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
  16. package/src/objects/AccountToTransactionsConnection.ts +33 -9
  17. package/src/objects/AccountToWalletsConnection.ts +13 -4
  18. package/src/objects/ApiToken.ts +13 -3
  19. package/src/objects/Balances.ts +17 -3
  20. package/src/objects/BlockchainBalance.ts +34 -9
  21. package/src/objects/Channel.ts +61 -16
  22. package/src/objects/ChannelClosingTransaction.ts +81 -61
  23. package/src/objects/ChannelFees.ts +16 -5
  24. package/src/objects/ChannelOpeningTransaction.ts +81 -61
  25. package/src/objects/ChannelSnapshot.ts +66 -6
  26. package/src/objects/ChannelToTransactionsConnection.ts +26 -6
  27. package/src/objects/Connection.ts +205 -10
  28. package/src/objects/CreateApiTokenInput.ts +8 -2
  29. package/src/objects/CreateApiTokenOutput.ts +9 -3
  30. package/src/objects/CreateInvoiceInput.ts +14 -5
  31. package/src/objects/CreateInvoiceOutput.ts +7 -2
  32. package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
  33. package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
  34. package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
  35. package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
  36. package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
  37. package/src/objects/CreateTestModePaymentInput.ts +12 -3
  38. package/src/objects/CreateTestModePaymentoutput.ts +12 -2
  39. package/src/objects/CreateUmaInvoiceInput.ts +13 -3
  40. package/src/objects/CurrencyAmount.ts +13 -2
  41. package/src/objects/DeclineToSignMessagesInput.ts +9 -2
  42. package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
  43. package/src/objects/DeleteApiTokenInput.ts +7 -2
  44. package/src/objects/DeleteApiTokenOutput.ts +7 -2
  45. package/src/objects/Deposit.ts +77 -61
  46. package/src/objects/Entity.ts +184 -2
  47. package/src/objects/FeeEstimate.ts +12 -3
  48. package/src/objects/FundNodeInput.ts +9 -3
  49. package/src/objects/FundNodeOutput.ts +11 -3
  50. package/src/objects/GraphNode.ts +21 -5
  51. package/src/objects/Hop.ts +27 -9
  52. package/src/objects/HtlcAttemptFailureCode.ts +2 -0
  53. package/src/objects/IdAndSignature.ts +8 -2
  54. package/src/objects/IncomingPayment.ts +33 -7
  55. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  56. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  57. package/src/objects/Invoice.ts +91 -24
  58. package/src/objects/InvoiceData.ts +75 -6
  59. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  60. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  61. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  62. package/src/objects/LightningTransaction.ts +171 -28
  63. package/src/objects/LightsparkNode.ts +311 -208
  64. package/src/objects/LightsparkNodeOwner.ts +35 -4
  65. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  66. package/src/objects/LightsparkNodeWithOSK.ts +97 -15
  67. package/src/objects/LightsparkNodeWithRemoteSigning.ts +93 -13
  68. package/src/objects/Node.ts +269 -67
  69. package/src/objects/NodeAddress.ts +8 -2
  70. package/src/objects/NodeToAddressesConnection.ts +13 -3
  71. package/src/objects/OnChainTransaction.ts +156 -44
  72. package/src/objects/OutgoingPayment.ts +127 -14
  73. package/src/objects/OutgoingPaymentAttempt.ts +57 -8
  74. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  75. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  76. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  77. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  78. package/src/objects/PageInfo.ts +14 -6
  79. package/src/objects/PayInvoiceInput.ts +12 -3
  80. package/src/objects/PayInvoiceOutput.ts +7 -2
  81. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  82. package/src/objects/PaymentRequest.ts +81 -5
  83. package/src/objects/PaymentRequestData.ts +81 -4
  84. package/src/objects/PostTransactionData.ts +12 -3
  85. package/src/objects/RegisterPaymentInput.ts +10 -2
  86. package/src/objects/RegisterPaymentOutput.ts +9 -2
  87. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  88. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  89. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  90. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  91. package/src/objects/RequestWithdrawalInput.ts +12 -2
  92. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  93. package/src/objects/RichText.ts +7 -2
  94. package/src/objects/RoutingTransaction.ts +62 -41
  95. package/src/objects/ScreenNodeInput.ts +8 -2
  96. package/src/objects/ScreenNodeOutput.ts +7 -2
  97. package/src/objects/Secret.ts +8 -2
  98. package/src/objects/SendPaymentInput.ts +11 -2
  99. package/src/objects/SendPaymentOutput.ts +7 -2
  100. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  101. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  102. package/src/objects/SignInvoiceInput.ts +9 -2
  103. package/src/objects/SignInvoiceOutput.ts +7 -2
  104. package/src/objects/SignMessagesInput.ts +13 -3
  105. package/src/objects/SignMessagesOutput.ts +13 -3
  106. package/src/objects/Signable.ts +10 -3
  107. package/src/objects/SignablePayload.ts +18 -5
  108. package/src/objects/Transaction.ts +260 -9
  109. package/src/objects/TransactionFailures.ts +11 -4
  110. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  111. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  112. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  113. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  114. package/src/objects/Wallet.ts +130 -5
  115. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  116. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  117. package/src/objects/Withdrawal.ts +77 -61
  118. package/src/objects/WithdrawalRequest.ts +25 -4
  119. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  120. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  121. package/src/objects/index.ts +5 -2
  122. package/src/tests/integration/client.test.ts +46 -7
  123. package/src/tests/serialization.test.ts +18 -0
@@ -1,7 +1,7 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  /** This interface is used by all the entities in the Lightspark system. It defines a few core fields that are available everywhere. Any object that implements this interface can be queried using the `entity` query and its ID. **/
4
- type Entity = {
4
+ interface Entity {
5
5
  /**
6
6
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
7
7
  * string.
@@ -16,7 +16,7 @@ type Entity = {
16
16
 
17
17
  /** The typename of the object **/
18
18
  typename: string;
19
- };
19
+ }
20
20
 
21
21
  export const FRAGMENT = `
22
22
  fragment EntityFragment on Entity {
@@ -455,6 +455,33 @@ fragment EntityFragment on Entity {
455
455
  }
456
456
  }
457
457
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
458
+ lightspark_node_with_o_s_k_balances: balances {
459
+ __typename
460
+ balances_owned_balance: owned_balance {
461
+ __typename
462
+ currency_amount_original_value: original_value
463
+ currency_amount_original_unit: original_unit
464
+ currency_amount_preferred_currency_unit: preferred_currency_unit
465
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
466
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
467
+ }
468
+ balances_available_to_send_balance: available_to_send_balance {
469
+ __typename
470
+ currency_amount_original_value: original_value
471
+ currency_amount_original_unit: original_unit
472
+ currency_amount_preferred_currency_unit: preferred_currency_unit
473
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
474
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
475
+ }
476
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
477
+ __typename
478
+ currency_amount_original_value: original_value
479
+ currency_amount_original_unit: original_unit
480
+ currency_amount_preferred_currency_unit: preferred_currency_unit
481
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
482
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
483
+ }
484
+ }
458
485
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
459
486
  __typename
460
487
  secret_encrypted_value: encrypted_value
@@ -560,6 +587,33 @@ fragment EntityFragment on Entity {
560
587
  }
561
588
  }
562
589
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
590
+ lightspark_node_with_remote_signing_balances: balances {
591
+ __typename
592
+ balances_owned_balance: owned_balance {
593
+ __typename
594
+ currency_amount_original_value: original_value
595
+ currency_amount_original_unit: original_unit
596
+ currency_amount_preferred_currency_unit: preferred_currency_unit
597
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
598
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
599
+ }
600
+ balances_available_to_send_balance: available_to_send_balance {
601
+ __typename
602
+ currency_amount_original_value: original_value
603
+ currency_amount_original_unit: original_unit
604
+ currency_amount_preferred_currency_unit: preferred_currency_unit
605
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
606
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
607
+ }
608
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
609
+ __typename
610
+ currency_amount_original_value: original_value
611
+ currency_amount_original_unit: original_unit
612
+ currency_amount_preferred_currency_unit: preferred_currency_unit
613
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
614
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
615
+ }
616
+ }
563
617
  }
564
618
  }
565
619
  }
@@ -672,6 +726,33 @@ fragment EntityFragment on Entity {
672
726
  }
673
727
  }
674
728
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
729
+ lightspark_node_with_o_s_k_balances: balances {
730
+ __typename
731
+ balances_owned_balance: owned_balance {
732
+ __typename
733
+ currency_amount_original_value: original_value
734
+ currency_amount_original_unit: original_unit
735
+ currency_amount_preferred_currency_unit: preferred_currency_unit
736
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
737
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
738
+ }
739
+ balances_available_to_send_balance: available_to_send_balance {
740
+ __typename
741
+ currency_amount_original_value: original_value
742
+ currency_amount_original_unit: original_unit
743
+ currency_amount_preferred_currency_unit: preferred_currency_unit
744
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
745
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
746
+ }
747
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
748
+ __typename
749
+ currency_amount_original_value: original_value
750
+ currency_amount_original_unit: original_unit
751
+ currency_amount_preferred_currency_unit: preferred_currency_unit
752
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
753
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
754
+ }
755
+ }
675
756
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
676
757
  __typename
677
758
  secret_encrypted_value: encrypted_value
@@ -777,6 +858,33 @@ fragment EntityFragment on Entity {
777
858
  }
778
859
  }
779
860
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
861
+ lightspark_node_with_remote_signing_balances: balances {
862
+ __typename
863
+ balances_owned_balance: owned_balance {
864
+ __typename
865
+ currency_amount_original_value: original_value
866
+ currency_amount_original_unit: original_unit
867
+ currency_amount_preferred_currency_unit: preferred_currency_unit
868
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
869
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
870
+ }
871
+ balances_available_to_send_balance: available_to_send_balance {
872
+ __typename
873
+ currency_amount_original_value: original_value
874
+ currency_amount_original_unit: original_unit
875
+ currency_amount_preferred_currency_unit: preferred_currency_unit
876
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
877
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
878
+ }
879
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
880
+ __typename
881
+ currency_amount_original_value: original_value
882
+ currency_amount_original_unit: original_unit
883
+ currency_amount_preferred_currency_unit: preferred_currency_unit
884
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
885
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
886
+ }
887
+ }
780
888
  }
781
889
  ... on OutgoingPayment {
782
890
  __typename
@@ -939,6 +1047,33 @@ fragment EntityFragment on Entity {
939
1047
  }
940
1048
  }
941
1049
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
1050
+ lightspark_node_with_o_s_k_balances: balances {
1051
+ __typename
1052
+ balances_owned_balance: owned_balance {
1053
+ __typename
1054
+ currency_amount_original_value: original_value
1055
+ currency_amount_original_unit: original_unit
1056
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1057
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1058
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1059
+ }
1060
+ balances_available_to_send_balance: available_to_send_balance {
1061
+ __typename
1062
+ currency_amount_original_value: original_value
1063
+ currency_amount_original_unit: original_unit
1064
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1065
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1066
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1067
+ }
1068
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
1069
+ __typename
1070
+ currency_amount_original_value: original_value
1071
+ currency_amount_original_unit: original_unit
1072
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1073
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1074
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1075
+ }
1076
+ }
942
1077
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
943
1078
  __typename
944
1079
  secret_encrypted_value: encrypted_value
@@ -1044,6 +1179,33 @@ fragment EntityFragment on Entity {
1044
1179
  }
1045
1180
  }
1046
1181
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
1182
+ lightspark_node_with_remote_signing_balances: balances {
1183
+ __typename
1184
+ balances_owned_balance: owned_balance {
1185
+ __typename
1186
+ currency_amount_original_value: original_value
1187
+ currency_amount_original_unit: original_unit
1188
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1189
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1190
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1191
+ }
1192
+ balances_available_to_send_balance: available_to_send_balance {
1193
+ __typename
1194
+ currency_amount_original_value: original_value
1195
+ currency_amount_original_unit: original_unit
1196
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1197
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1198
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1199
+ }
1200
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
1201
+ __typename
1202
+ currency_amount_original_value: original_value
1203
+ currency_amount_original_unit: original_unit
1204
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1205
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1206
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1207
+ }
1208
+ }
1047
1209
  }
1048
1210
  }
1049
1211
  }
@@ -1097,6 +1259,10 @@ fragment EntityFragment on Entity {
1097
1259
  }
1098
1260
  outgoing_payment_attempt_channel_snapshot: channel_snapshot {
1099
1261
  __typename
1262
+ channel_snapshot_channel: channel {
1263
+ id
1264
+ }
1265
+ channel_snapshot_timestamp: timestamp
1100
1266
  channel_snapshot_local_balance: local_balance {
1101
1267
  __typename
1102
1268
  currency_amount_original_value: original_value
@@ -1121,6 +1287,22 @@ fragment EntityFragment on Entity {
1121
1287
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1122
1288
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1123
1289
  }
1290
+ channel_snapshot_remote_balance: remote_balance {
1291
+ __typename
1292
+ currency_amount_original_value: original_value
1293
+ currency_amount_original_unit: original_unit
1294
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1295
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1296
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1297
+ }
1298
+ channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
1299
+ __typename
1300
+ currency_amount_original_value: original_value
1301
+ currency_amount_original_unit: original_unit
1302
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1303
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1304
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1305
+ }
1124
1306
  }
1125
1307
  }
1126
1308
  ... on RoutingTransaction {
@@ -1,14 +1,17 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This object represents the estimated L1 transaction fees for the Bitcoin network. Fee estimates are separated by potential confirmation speeds for settlement. **/
7
- type FeeEstimate = {
10
+ interface FeeEstimate {
8
11
  feeFast: CurrencyAmount;
9
12
 
10
13
  feeMin: CurrencyAmount;
11
- };
14
+ }
12
15
 
13
16
  export const FeeEstimateFromJson = (obj: any): FeeEstimate => {
14
17
  return {
@@ -16,6 +19,12 @@ export const FeeEstimateFromJson = (obj: any): FeeEstimate => {
16
19
  feeMin: CurrencyAmountFromJson(obj["fee_estimate_fee_min"]),
17
20
  } as FeeEstimate;
18
21
  };
22
+ export const FeeEstimateToJson = (obj: FeeEstimate): any => {
23
+ return {
24
+ fee_estimate_fee_fast: CurrencyAmountToJson(obj.feeFast),
25
+ fee_estimate_fee_min: CurrencyAmountToJson(obj.feeMin),
26
+ };
27
+ };
19
28
 
20
29
  export const FRAGMENT = `
21
30
  fragment FeeEstimateFragment on FeeEstimate {
@@ -1,10 +1,10 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type FundNodeInput = {
3
+ interface FundNodeInput {
4
4
  nodeId: string;
5
5
 
6
- amountSats?: number;
7
- };
6
+ amountSats?: number | undefined;
7
+ }
8
8
 
9
9
  export const FundNodeInputFromJson = (obj: any): FundNodeInput => {
10
10
  return {
@@ -12,5 +12,11 @@ export const FundNodeInputFromJson = (obj: any): FundNodeInput => {
12
12
  amountSats: obj["fund_node_input_amount_sats"],
13
13
  } as FundNodeInput;
14
14
  };
15
+ export const FundNodeInputToJson = (obj: FundNodeInput): any => {
16
+ return {
17
+ fund_node_input_node_id: obj.nodeId,
18
+ fund_node_input_amount_sats: obj.amountSats,
19
+ };
20
+ };
15
21
 
16
22
  export default FundNodeInput;
@@ -1,17 +1,25 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
- type FundNodeOutput = {
9
+ interface FundNodeOutput {
7
10
  amount: CurrencyAmount;
8
- };
11
+ }
9
12
 
10
13
  export const FundNodeOutputFromJson = (obj: any): FundNodeOutput => {
11
14
  return {
12
15
  amount: CurrencyAmountFromJson(obj["fund_node_output_amount"]),
13
16
  } as FundNodeOutput;
14
17
  };
18
+ export const FundNodeOutputToJson = (obj: FundNodeOutput): any => {
19
+ return {
20
+ fund_node_output_amount: CurrencyAmountToJson(obj.amount),
21
+ };
22
+ };
15
23
 
16
24
  export const FRAGMENT = `
17
25
  fragment FundNodeOutputFragment on FundNodeOutput {
@@ -4,13 +4,14 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
7
+ import type Entity from "./Entity.js";
7
8
  import type Node from "./Node.js";
8
9
  import type NodeAddressType from "./NodeAddressType.js";
9
10
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
10
11
  import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
11
12
 
12
13
  /** This object represents a node that exists on the Lightning Network, including nodes not managed by Lightspark. You can retrieve this object to get publicly available information about any node on the Lightning Network. **/
13
- class GraphNode implements Node {
14
+ class GraphNode implements Node, Entity {
14
15
  constructor(
15
16
  public readonly id: string,
16
17
  public readonly createdAt: string,
@@ -18,10 +19,10 @@ class GraphNode implements Node {
18
19
  public readonly bitcoinNetwork: BitcoinNetwork,
19
20
  public readonly displayName: string,
20
21
  public readonly typename: string,
21
- public readonly alias?: string,
22
- public readonly color?: string,
23
- public readonly conductivity?: number,
24
- public readonly publicKey?: string,
22
+ public readonly alias?: string | undefined,
23
+ public readonly color?: string | undefined,
24
+ public readonly conductivity?: number | undefined,
25
+ public readonly publicKey?: string | undefined,
25
26
  ) {
26
27
  autoBind(this);
27
28
  }
@@ -74,6 +75,21 @@ ${FRAGMENT}
74
75
  constructObject: (data: any) => GraphNodeFromJson(data.entity),
75
76
  };
76
77
  }
78
+
79
+ public toJson() {
80
+ return {
81
+ __typename: "GraphNode",
82
+ graph_node_id: this.id,
83
+ graph_node_created_at: this.createdAt,
84
+ graph_node_updated_at: this.updatedAt,
85
+ graph_node_alias: this.alias,
86
+ graph_node_bitcoin_network: this.bitcoinNetwork,
87
+ graph_node_color: this.color,
88
+ graph_node_conductivity: this.conductivity,
89
+ graph_node_display_name: this.displayName,
90
+ graph_node_public_key: this.publicKey,
91
+ };
92
+ }
77
93
  }
78
94
 
79
95
  export const GraphNodeFromJson = (obj: any): GraphNode => {
@@ -2,11 +2,13 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
 
8
10
  /** This object represents a specific node that existed on a particular payment route. You can retrieve this object to get information about a node on a particular payment path and all payment-relevant information for that node. **/
9
- type Hop = Entity & {
11
+ interface Hop {
10
12
  /**
11
13
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
12
14
  * string.
@@ -26,20 +28,20 @@ type Hop = Entity & {
26
28
  typename: string;
27
29
 
28
30
  /** The destination node of the hop. **/
29
- destinationId?: string;
31
+ destinationId?: string | undefined;
30
32
 
31
33
  /** The public key of the node to which the hop is bound. **/
32
- publicKey?: string;
34
+ publicKey?: string | undefined;
33
35
 
34
36
  /** The amount that is to be forwarded to the destination node. **/
35
- amountToForward?: CurrencyAmount;
37
+ amountToForward?: CurrencyAmount | undefined;
36
38
 
37
39
  /** The fees to be collected by the source node for forwarding the payment over the hop. **/
38
- fee?: CurrencyAmount;
40
+ fee?: CurrencyAmount | undefined;
39
41
 
40
42
  /** The block height at which an unsettled HTLC is considered expired. **/
41
- expiryBlockHeight?: number;
42
- };
43
+ expiryBlockHeight?: number | undefined;
44
+ }
43
45
 
44
46
  export const HopFromJson = (obj: any): Hop => {
45
47
  return {
@@ -57,6 +59,22 @@ export const HopFromJson = (obj: any): Hop => {
57
59
  expiryBlockHeight: obj["hop_expiry_block_height"],
58
60
  } as Hop;
59
61
  };
62
+ export const HopToJson = (obj: Hop): any => {
63
+ return {
64
+ __typename: "Hop",
65
+ hop_id: obj.id,
66
+ hop_created_at: obj.createdAt,
67
+ hop_updated_at: obj.updatedAt,
68
+ hop_destination: { id: obj.destinationId } ?? undefined,
69
+ hop_index: obj.index,
70
+ hop_public_key: obj.publicKey,
71
+ hop_amount_to_forward: obj.amountToForward
72
+ ? CurrencyAmountToJson(obj.amountToForward)
73
+ : undefined,
74
+ hop_fee: obj.fee ? CurrencyAmountToJson(obj.fee) : undefined,
75
+ hop_expiry_block_height: obj.expiryBlockHeight,
76
+ };
77
+ };
60
78
 
61
79
  export const FRAGMENT = `
62
80
  fragment HopFragment on Hop {
@@ -56,6 +56,8 @@ export enum HtlcAttemptFailureCode {
56
56
 
57
57
  INVALID_ONION_PAYLOAD = "INVALID_ONION_PAYLOAD",
58
58
 
59
+ INVALID_ONION_BLINDING = "INVALID_ONION_BLINDING",
60
+
59
61
  INTERNAL_FAILURE = "INTERNAL_FAILURE",
60
62
 
61
63
  UNKNOWN_FAILURE = "UNKNOWN_FAILURE",
@@ -1,12 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type IdAndSignature = {
3
+ interface IdAndSignature {
4
4
  /** The id of the message. **/
5
5
  id: string;
6
6
 
7
7
  /** The signature of the message. **/
8
8
  signature: string;
9
- };
9
+ }
10
10
 
11
11
  export const IdAndSignatureFromJson = (obj: any): IdAndSignature => {
12
12
  return {
@@ -14,5 +14,11 @@ export const IdAndSignatureFromJson = (obj: any): IdAndSignature => {
14
14
  signature: obj["id_and_signature_signature"],
15
15
  } as IdAndSignature;
16
16
  };
17
+ export const IdAndSignatureToJson = (obj: IdAndSignature): any => {
18
+ return {
19
+ id_and_signature_id: obj.id,
20
+ id_and_signature_signature: obj.signature,
21
+ };
22
+ };
17
23
 
18
24
  export default IdAndSignature;
@@ -4,17 +4,25 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
7
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import {
8
+ CurrencyAmountFromJson,
9
+ CurrencyAmountToJson,
10
+ } from "./CurrencyAmount.js";
11
+ import type Entity from "./Entity.js";
8
12
  import type IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
9
13
  import type IncomingPaymentToAttemptsConnection from "./IncomingPaymentToAttemptsConnection.js";
10
14
  import { IncomingPaymentToAttemptsConnectionFromJson } from "./IncomingPaymentToAttemptsConnection.js";
11
15
  import type LightningTransaction from "./LightningTransaction.js";
12
16
  import type PostTransactionData from "./PostTransactionData.js";
13
- import { PostTransactionDataFromJson } from "./PostTransactionData.js";
17
+ import {
18
+ PostTransactionDataFromJson,
19
+ PostTransactionDataToJson,
20
+ } from "./PostTransactionData.js";
21
+ import type Transaction from "./Transaction.js";
14
22
  import TransactionStatus from "./TransactionStatus.js";
15
23
 
16
24
  /** This object represents any payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific payment received by a Lightspark node. **/
17
- class IncomingPayment implements LightningTransaction {
25
+ class IncomingPayment implements LightningTransaction, Transaction, Entity {
18
26
  constructor(
19
27
  public readonly id: string,
20
28
  public readonly createdAt: string,
@@ -23,10 +31,10 @@ class IncomingPayment implements LightningTransaction {
23
31
  public readonly amount: CurrencyAmount,
24
32
  public readonly destinationId: string,
25
33
  public readonly typename: string,
26
- public readonly resolvedAt?: string,
27
- public readonly transactionHash?: string,
28
- public readonly paymentRequestId?: string,
29
- public readonly umaPostTransactionData?: PostTransactionData[],
34
+ public readonly resolvedAt?: string | undefined,
35
+ public readonly transactionHash?: string | undefined,
36
+ public readonly paymentRequestId?: string | undefined,
37
+ public readonly umaPostTransactionData?: PostTransactionData[] | undefined,
30
38
  ) {
31
39
  autoBind(this);
32
40
  }
@@ -106,6 +114,24 @@ ${FRAGMENT}
106
114
  constructObject: (data: any) => IncomingPaymentFromJson(data.entity),
107
115
  };
108
116
  }
117
+
118
+ public toJson() {
119
+ return {
120
+ __typename: "IncomingPayment",
121
+ incoming_payment_id: this.id,
122
+ incoming_payment_created_at: this.createdAt,
123
+ incoming_payment_updated_at: this.updatedAt,
124
+ incoming_payment_status: this.status,
125
+ incoming_payment_resolved_at: this.resolvedAt,
126
+ incoming_payment_amount: CurrencyAmountToJson(this.amount),
127
+ incoming_payment_transaction_hash: this.transactionHash,
128
+ incoming_payment_destination: { id: this.destinationId },
129
+ incoming_payment_payment_request:
130
+ { id: this.paymentRequestId } ?? undefined,
131
+ incoming_payment_uma_post_transaction_data:
132
+ this.umaPostTransactionData?.map((e) => PostTransactionDataToJson(e)),
133
+ };
134
+ }
109
135
  }
110
136
 
111
137
  export const IncomingPaymentFromJson = (obj: any): IncomingPayment => {
@@ -2,12 +2,14 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
  import IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
8
10
 
9
11
  /** This object represents any attempted payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific incoming payment attempt. **/
10
- type IncomingPaymentAttempt = Entity & {
12
+ interface IncomingPaymentAttempt {
11
13
  /**
12
14
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
13
15
  * string.
@@ -33,8 +35,8 @@ type IncomingPaymentAttempt = Entity & {
33
35
  typename: string;
34
36
 
35
37
  /** The time the incoming payment attempt failed or succeeded. **/
36
- resolvedAt?: string;
37
- };
38
+ resolvedAt?: string | undefined;
39
+ }
38
40
 
39
41
  export const IncomingPaymentAttemptFromJson = (
40
42
  obj: any,
@@ -52,6 +54,20 @@ export const IncomingPaymentAttemptFromJson = (
52
54
  resolvedAt: obj["incoming_payment_attempt_resolved_at"],
53
55
  } as IncomingPaymentAttempt;
54
56
  };
57
+ export const IncomingPaymentAttemptToJson = (
58
+ obj: IncomingPaymentAttempt,
59
+ ): any => {
60
+ return {
61
+ __typename: "IncomingPaymentAttempt",
62
+ incoming_payment_attempt_id: obj.id,
63
+ incoming_payment_attempt_created_at: obj.createdAt,
64
+ incoming_payment_attempt_updated_at: obj.updatedAt,
65
+ incoming_payment_attempt_status: obj.status,
66
+ incoming_payment_attempt_resolved_at: obj.resolvedAt,
67
+ incoming_payment_attempt_amount: CurrencyAmountToJson(obj.amount),
68
+ incoming_payment_attempt_channel: { id: obj.channelId },
69
+ };
70
+ };
55
71
 
56
72
  export const FRAGMENT = `
57
73
  fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {
@@ -1,13 +1,15 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type IncomingPaymentAttempt from "./IncomingPaymentAttempt.js";
5
- import { IncomingPaymentAttemptFromJson } from "./IncomingPaymentAttempt.js";
4
+ import {
5
+ IncomingPaymentAttemptFromJson,
6
+ IncomingPaymentAttemptToJson,
7
+ } from "./IncomingPaymentAttempt.js";
6
8
  import type PageInfo from "./PageInfo.js";
7
- import { PageInfoFromJson } from "./PageInfo.js";
9
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
8
10
 
9
11
  /** The connection from incoming payment to all attempts. **/
10
- type IncomingPaymentToAttemptsConnection = Connection & {
12
+ interface IncomingPaymentToAttemptsConnection {
11
13
  /**
12
14
  * The total count of objects in this connection, using the current filters. It is different from the
13
15
  * number of objects returned in the current page (in the `entities` field).
@@ -22,7 +24,7 @@ type IncomingPaymentToAttemptsConnection = Connection & {
22
24
 
23
25
  /** The typename of the object **/
24
26
  typename: string;
25
- };
27
+ }
26
28
 
27
29
  export const IncomingPaymentToAttemptsConnectionFromJson = (
28
30
  obj: any,
@@ -38,6 +40,20 @@ export const IncomingPaymentToAttemptsConnectionFromJson = (
38
40
  typename: "IncomingPaymentToAttemptsConnection",
39
41
  } as IncomingPaymentToAttemptsConnection;
40
42
  };
43
+ export const IncomingPaymentToAttemptsConnectionToJson = (
44
+ obj: IncomingPaymentToAttemptsConnection,
45
+ ): any => {
46
+ return {
47
+ __typename: "IncomingPaymentToAttemptsConnection",
48
+ incoming_payment_to_attempts_connection_count: obj.count,
49
+ incoming_payment_to_attempts_connection_page_info: PageInfoToJson(
50
+ obj.pageInfo,
51
+ ),
52
+ incoming_payment_to_attempts_connection_entities: obj.entities.map((e) =>
53
+ IncomingPaymentAttemptToJson(e),
54
+ ),
55
+ };
56
+ };
41
57
 
42
58
  export const FRAGMENT = `
43
59
  fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection {