mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 18:02:54 +01:00
2022 04 14 dlctxsigner err msg (#4262)
* Improve error messages for invariants in DLCTxSigner * scalafmt
This commit is contained in:
parent
0a092e4e03
commit
07209ce670
@ -44,9 +44,14 @@ case class DLCTxSigner(
|
||||
}
|
||||
|
||||
if (isInitiator) {
|
||||
require(fundingKey.publicKey == offer.pubKeys.fundingKey &&
|
||||
finalAddress == offer.pubKeys.payoutAddress,
|
||||
"Given keys do not match public key and address in offer")
|
||||
require(
|
||||
fundingKey.publicKey == offer.pubKeys.fundingKey,
|
||||
s"Given keys do not match public key and address in offer, funding.publicKey=${fundingKey.publicKey} offer.pubKeys.fundingKey=${offer.pubKeys.fundingKey}"
|
||||
)
|
||||
require(
|
||||
finalAddress == offer.pubKeys.payoutAddress,
|
||||
s"Final address and offerer payout address must be identical finalAddress=$finalAddress offer.pubKeys.payoutAddress=${offer.pubKeys.payoutAddress}"
|
||||
)
|
||||
val fundingUtxosAsInputs =
|
||||
fundingUtxos
|
||||
.sortBy(_.outPoint.bytes)
|
||||
@ -57,14 +62,21 @@ case class DLCTxSigner(
|
||||
fund.sequence)
|
||||
}
|
||||
.sortBy(_.inputSerialId)
|
||||
require(fundingUtxosAsInputs == offer.fundingInputs.sortBy(_.inputSerialId),
|
||||
"Funding ScriptSignatureParams did not match offer funding inputs")
|
||||
val sortedOfferInputs = offer.fundingInputs.sortBy(_.inputSerialId)
|
||||
|
||||
require(
|
||||
fundingUtxosAsInputs == sortedOfferInputs,
|
||||
s"Funding ScriptSignatureParams did not match offer funding inputs, fundingUtxosAsInputs=${fundingUtxosAsInputs} sortedOffererInputs=$sortedOfferInputs"
|
||||
)
|
||||
} else {
|
||||
require(
|
||||
fundingKey.publicKey == accept.pubKeys.fundingKey &&
|
||||
finalAddress == accept.pubKeys.payoutAddress,
|
||||
fundingKey.publicKey == accept.pubKeys.fundingKey,
|
||||
"Given keys do not match public key and address in accept"
|
||||
)
|
||||
require(
|
||||
finalAddress == accept.pubKeys.payoutAddress,
|
||||
s"Final address and acceptor payout address don't match, finalAddress=$finalAddress accept.pubKeys.payoutAddress=${accept.pubKeys.payoutAddress}"
|
||||
)
|
||||
val fundingUtxosAsInputs =
|
||||
fundingUtxos
|
||||
.sortBy(_.outPoint.bytes)
|
||||
@ -75,9 +87,10 @@ case class DLCTxSigner(
|
||||
fund.sequence)
|
||||
}
|
||||
.sortBy(_.inputSerialId)
|
||||
val sortedAcceptInputs = accept.fundingInputs.sortBy(_.inputSerialId)
|
||||
require(
|
||||
fundingUtxosAsInputs == accept.fundingInputs.sortBy(_.inputSerialId),
|
||||
"Funding ScriptSignatureParams did not match accept funding inputs"
|
||||
fundingUtxosAsInputs == sortedAcceptInputs,
|
||||
s"Funding ScriptSignatureParams did not match offer funding inputs, fundingUtxosAsInputs=${fundingUtxosAsInputs} sortedAcceptInputs=$sortedAcceptInputs"
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user