Skip to content

Commit 34644bd

Browse files
authored
Merge pull request #509 from bhandras/musig2-sweep-psbt
loopout: use psbt when obtaining the MuSig2 signature
2 parents e80852f + f8da106 commit 34644bd

File tree

6 files changed

+213
-201
lines changed

6 files changed

+213
-201
lines changed

loopout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ func (s *loopOutSwap) createMuSig2SweepTxn(
13531353

13541354
// First assemble our taproot keyspend sweep transaction and get the
13551355
// sig hash.
1356-
sweepTx, sigHash, err := s.sweeper.CreateUnsignedTaprootKeySpendSweepTx(
1356+
sweepTx, sweepTxPsbt, sigHash, err := s.sweeper.CreateUnsignedTaprootKeySpendSweepTx(
13571357
ctx, uint32(s.height), s.htlc, htlcOutpoint, htlcValue, fee,
13581358
s.DestAddr,
13591359
)
@@ -1387,7 +1387,7 @@ func (s *loopOutSwap) createMuSig2SweepTxn(
13871387
serverNonce, serverSig, err := s.swapKit.server.MuSig2SignSweep(
13881388
ctx, s.SwapContract.ProtocolVersion, s.hash,
13891389
s.swapInvoicePaymentAddr, musig2SessionInfo.PublicNonce[:],
1390-
sigHash,
1390+
sweepTxPsbt,
13911391
)
13921392
if err != nil {
13931393
return nil, err

server_mock_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ func (s *serverMock) ReportRoutingResult(_ context.Context, _ lntypes.Hash,
256256
}
257257

258258
func (s *serverMock) MuSig2SignSweep(_ context.Context, _ loopdb.ProtocolVersion,
259-
_ lntypes.Hash, _ [32]byte, _ []byte, _ []byte) ([]byte, []byte, error) {
259+
_ lntypes.Hash, _ [32]byte, _ []byte, _ []byte) ([]byte,
260+
[]byte, error) {
260261

261262
return nil, nil, nil
262263
}

swap_server_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type swapServerClient interface {
126126
// htlc spend. Returns the server's nonce and partial signature.
127127
MuSig2SignSweep(ctx context.Context,
128128
protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash,
129-
paymentAddr [32]byte, nonce []byte, sigHash []byte) (
129+
paymentAddr [32]byte, nonce []byte, sweepTxPsbt []byte) (
130130
[]byte, []byte, error)
131131
}
132132

@@ -731,15 +731,15 @@ func (s *grpcSwapServerClient) ReportRoutingResult(ctx context.Context,
731731
// spend. Returns the server's nonce and partial signature.
732732
func (s *grpcSwapServerClient) MuSig2SignSweep(ctx context.Context,
733733
protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash,
734-
paymentAddr [32]byte, nonce []byte, sigHash []byte) (
734+
paymentAddr [32]byte, nonce []byte, sweepTxPsbt []byte) (
735735
[]byte, []byte, error) {
736736

737737
req := &looprpc.MuSig2SignSweepReq{
738738
ProtocolVersion: looprpc.ProtocolVersion(protocolVersion),
739739
SwapHash: swapHash[:],
740740
PaymentAddress: paymentAddr[:],
741741
Nonce: nonce,
742-
SigHash: sigHash,
742+
SweepTxPsbt: sweepTxPsbt,
743743
}
744744

745745
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)

0 commit comments

Comments
 (0)