Skip to content

Commit

Permalink
Merge pull request #509 from bhandras/musig2-sweep-psbt
Browse files Browse the repository at this point in the history
loopout: use psbt when obtaining the MuSig2 signature
  • Loading branch information
bhandras authored Jul 14, 2022
2 parents e80852f + f8da106 commit 34644bd
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 201 deletions.
4 changes: 2 additions & 2 deletions loopout.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ func (s *loopOutSwap) createMuSig2SweepTxn(

// First assemble our taproot keyspend sweep transaction and get the
// sig hash.
sweepTx, sigHash, err := s.sweeper.CreateUnsignedTaprootKeySpendSweepTx(
sweepTx, sweepTxPsbt, sigHash, err := s.sweeper.CreateUnsignedTaprootKeySpendSweepTx(
ctx, uint32(s.height), s.htlc, htlcOutpoint, htlcValue, fee,
s.DestAddr,
)
Expand Down Expand Up @@ -1387,7 +1387,7 @@ func (s *loopOutSwap) createMuSig2SweepTxn(
serverNonce, serverSig, err := s.swapKit.server.MuSig2SignSweep(
ctx, s.SwapContract.ProtocolVersion, s.hash,
s.swapInvoicePaymentAddr, musig2SessionInfo.PublicNonce[:],
sigHash,
sweepTxPsbt,
)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion server_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ func (s *serverMock) ReportRoutingResult(_ context.Context, _ lntypes.Hash,
}

func (s *serverMock) MuSig2SignSweep(_ context.Context, _ loopdb.ProtocolVersion,
_ lntypes.Hash, _ [32]byte, _ []byte, _ []byte) ([]byte, []byte, error) {
_ lntypes.Hash, _ [32]byte, _ []byte, _ []byte) ([]byte,
[]byte, error) {

return nil, nil, nil
}
6 changes: 3 additions & 3 deletions swap_server_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type swapServerClient interface {
// htlc spend. Returns the server's nonce and partial signature.
MuSig2SignSweep(ctx context.Context,
protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash,
paymentAddr [32]byte, nonce []byte, sigHash []byte) (
paymentAddr [32]byte, nonce []byte, sweepTxPsbt []byte) (
[]byte, []byte, error)
}

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

req := &looprpc.MuSig2SignSweepReq{
ProtocolVersion: looprpc.ProtocolVersion(protocolVersion),
SwapHash: swapHash[:],
PaymentAddress: paymentAddr[:],
Nonce: nonce,
SigHash: sigHash,
SweepTxPsbt: sweepTxPsbt,
}

rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
Expand Down
Loading

0 comments on commit 34644bd

Please sign in to comment.