Skip to content
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

Ripcord integration test #60

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions objects/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ func (obj Account) GetChannels(requester *requester.Requester, bitcoinNetwork Bi
id
}
channel_short_channel_id: short_channel_id
channel_channel_point: channel_point
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions objects/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type Channel struct {
// ShortChannelId The unique identifier of the channel on Lightning Network, which is the location in the chain that the channel was confirmed. The format is <block-height>:<tx-index>:<tx-output>.
ShortChannelId *string `json:"channel_short_channel_id"`

// Typename The typename of the object
ChannelPoint *string `json:"channel_channel_point"`

// Typename The typename of the object
Typename string `json:"__typename"`
}
Expand Down Expand Up @@ -165,6 +168,7 @@ fragment ChannelFragment on Channel {
id
}
channel_short_channel_id: short_channel_id
channel_channel_point: channel_point
}
`
)
Expand Down
119 changes: 119 additions & 0 deletions objects/lightspark_node_to_ripcord_updates_connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright ©, 2024-present, Lightspark Group, Inc. - All Rights Reserved
package objects

import "github.com/lightsparkdev/go-sdk/types"

type LightsparkNodeToRipcordUpdatesConnection struct {
FromDate types.Date `json:"lightspark_node_to_ripcord_updates_connection_from_date"`

ToDate types.Date `json:"lightspark_node_to_ripcord_updates_connection_to_date"`

// Entities The daily liquidity forecasts for the current page of this connection.
Entities []RipcordUpdate `json:"lightspark_node_to_ripcord_updates_connection_entities"`
}

const (
LightsparkNodeToRipcordUpdatesConnectionFragment = `
fragment LightsparkNodeToRipcordUpdatesConnectionFragment on LightsparkNodeToRipcordUpdatesConnection {
__typename
ripcord_update_commitment_number: commitment_number
ripcord_update_ripcord_update_status: ripcord_update_status
ripcord_update_data: data
ripcord_update_channel: channel {
__typename
channel_id: id
channel_created_at: created_at
channel_updated_at: updated_at
channel_funding_transaction: funding_transaction {
id
}
channel_capacity: capacity {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_local_balance: local_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_local_unsettled_balance: local_unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_remote_balance: remote_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_remote_unsettled_balance: remote_unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_unsettled_balance: unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_total_balance: total_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_status: status
channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
channel_commit_fee: commit_fee {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_fees: fees {
__typename
channel_fees_base_fee: base_fee {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_fees_fee_rate_per_mil: fee_rate_per_mil
}
channel_remote_node: remote_node {
id
}
channel_local_node: local_node {
id
}
channel_short_channel_id: short_channel_id
channel_channel_point: channel_point
}
}
`
)
128 changes: 128 additions & 0 deletions objects/lightspark_node_with_o_s_k.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ func (obj LightsparkNodeWithOSK) GetChannels(requester *requester.Requester, fir
id
}
channel_short_channel_id: short_channel_id
channel_channel_point: channel_point
}
}
}
Expand Down Expand Up @@ -523,3 +524,130 @@ func (obj LightsparkNodeWithOSK) GetDailyLiquidityForecasts(requester *requester
json.Unmarshal(jsonString, &result)
return result, nil
}

// GetRipcordUpdates The ripcord updates that correspond to state updates of channels that this node is part of.
func (obj LightsparkNodeWithOSK) GetRipcordUpdates(requester *requester.Requester, first *int, after *string) (*LightsparkNodeToRipcordUpdatesConnection, error) {
query := `query FetchLightsparkNodeToRipcordUpdatesConnection($entity_id: ID!, $first: Int, $after: String) {
entity(id: $entity_id) {
... on LightsparkNodeWithOSK {
ripcord_updates(, first: $first, after: $after) {
__typename
ripcord_update_commitment_number: commitment_number
ripcord_update_ripcord_update_status: ripcord_update_status
ripcord_update_data: data
ripcord_update_channel: channel {
__typename
channel_id: id
channel_created_at: created_at
channel_updated_at: updated_at
channel_funding_transaction: funding_transaction {
id
}
channel_capacity: capacity {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_local_balance: local_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_local_unsettled_balance: local_unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_remote_balance: remote_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_remote_unsettled_balance: remote_unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_unsettled_balance: unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_total_balance: total_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_status: status
channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
channel_commit_fee: commit_fee {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_fees: fees {
__typename
channel_fees_base_fee: base_fee {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_fees_fee_rate_per_mil: fee_rate_per_mil
}
channel_remote_node: remote_node {
id
}
channel_local_node: local_node {
id
}
channel_short_channel_id: short_channel_id
channel_channel_point: channel_point
}
}
}
}
}`
variables := map[string]interface{}{
"entity_id": obj.Id,
"first": first,
"after": after,
}

response, err := requester.ExecuteGraphql(query, variables, nil)
if err != nil {
return nil, err
}

output := response["entity"].(map[string]interface{})["ripcord_updates"].(map[string]interface{})
var result *LightsparkNodeToRipcordUpdatesConnection
jsonString, err := json.Marshal(output)
json.Unmarshal(jsonString, &result)
return result, nil
}
Loading
Loading