Skip to content

Commit 268c2f0

Browse files
committed
staticaddr: add swap hash to deposit structs
1 parent f54d580 commit 268c2f0

File tree

6 files changed

+424
-385
lines changed

6 files changed

+424
-385
lines changed

loopd/swapclient_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
19241924
Outpoint: outpoint,
19251925
Value: int64(d.Value),
19261926
ConfirmationHeight: d.ConfirmationHeight,
1927+
SwapHash: d.SwapHash[:],
19271928
}
19281929

19291930
clientDeposits = append(clientDeposits, deposit)

looprpc/client.pb.go

Lines changed: 396 additions & 384 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,12 @@ message Deposit {
19101910
loop-in swap anymore.
19111911
*/
19121912
int64 blocks_until_expiry = 6;
1913+
1914+
/*
1915+
The swap hash of the swap that this deposit is part of. This field is only
1916+
set if the deposit is part of a loop-in swap.
1917+
*/
1918+
bytes swap_hash = 7;
19131919
}
19141920

19151921
message StaticAddressWithdrawal {

looprpc/client.swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,11 @@
860860
"type": "string",
861861
"format": "int64",
862862
"description": "The number of blocks that are left until the deposit cannot be used for a\nloop-in swap anymore."
863+
},
864+
"swap_hash": {
865+
"type": "string",
866+
"format": "byte",
867+
"description": "The swap hash of the swap that this deposit is part of. This field is only\nset if the deposit is part of a loop-in swap."
863868
}
864869
}
865870
},

staticaddr/deposit/deposit.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/btcsuite/btcd/chaincfg/chainhash"
1010
"github.com/btcsuite/btcd/wire"
1111
"github.com/lightninglabs/loop/fsm"
12+
"github.com/lightningnetwork/lnd/lntypes"
1213
)
1314

1415
// ID is a unique identifier for a deposit.
@@ -52,7 +53,11 @@ type Deposit struct {
5253
// ExpirySweepTxid is the transaction id of the expiry sweep.
5354
ExpirySweepTxid chainhash.Hash
5455

55-
// FinalizedWithdrawalTx is the coop signed withdrawal transaction. It
56+
// SwapHash is an optional reference to a static address loop-in swap
57+
// that used this deposit. Nil if the deposit was not used in a swap.
58+
SwapHash *lntypes.Hash
59+
60+
// FinalizedWithdrawalTx is the coop-signed withdrawal transaction. It
5661
// is republished on new block arrivals and on client restarts.
5762
FinalizedWithdrawalTx *wire.MsgTx
5863

staticaddr/deposit/sql_store.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/lightninglabs/loop/loopdb"
1414
"github.com/lightninglabs/loop/loopdb/sqlc"
1515
"github.com/lightningnetwork/lnd/clock"
16+
"github.com/lightningnetwork/lnd/lntypes"
1617
)
1718

1819
// SqlStore is the backing store for static address deposits.
@@ -270,6 +271,14 @@ func ToDeposit(row sqlc.Deposit, lastUpdate sqlc.DepositUpdate) (*Deposit,
270271
}
271272
}
272273

274+
var swapHash lntypes.Hash
275+
if row.SwapHash != nil {
276+
swapHash, err = lntypes.MakeHash(row.SwapHash)
277+
if err != nil {
278+
return nil, err
279+
}
280+
}
281+
273282
return &Deposit{
274283
ID: id,
275284
state: fsm.StateType(lastUpdate.UpdateState),
@@ -281,6 +290,7 @@ func ToDeposit(row sqlc.Deposit, lastUpdate sqlc.DepositUpdate) (*Deposit,
281290
ConfirmationHeight: row.ConfirmationHeight,
282291
TimeOutSweepPkScript: row.TimeoutSweepPkScript,
283292
ExpirySweepTxid: expirySweepTxid,
293+
SwapHash: &swapHash,
284294
FinalizedWithdrawalTx: finalizedWithdrawalTx,
285295
}, nil
286296
}

0 commit comments

Comments
 (0)