mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
simplify non-depth peg-in validity checking
This commit is contained in:
parent
257602efc1
commit
e348f8248e
3 changed files with 4 additions and 7 deletions
|
|
@ -2357,7 +2357,7 @@ CScript calculate_contract(const CScript& federationRedeemScript, const CScript&
|
||||||
return scriptDestination;
|
return scriptDestination;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout) {
|
bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout, bool check_depth) {
|
||||||
|
|
||||||
// Format on stack is as follows:
|
// Format on stack is as follows:
|
||||||
// 1) value - the value of the pegin output
|
// 1) value - the value of the pegin output
|
||||||
|
|
@ -2473,8 +2473,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, validate peg-in via rpc call
|
// Finally, validate peg-in via rpc call
|
||||||
if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
|
if (check_depth && GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
|
||||||
// TODO-PEGIN return useful error message
|
|
||||||
return IsConfirmedBitcoinBlock(merkle_block.header.GetHash(), GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH));
|
return IsConfirmedBitcoinBlock(merkle_block.header.GetHash(), GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ void ThreadScriptCheck();
|
||||||
/** Check if bitcoind connection via RPC is correctly working*/
|
/** Check if bitcoind connection via RPC is correctly working*/
|
||||||
bool BitcoindRPCCheck(bool init);
|
bool BitcoindRPCCheck(bool init);
|
||||||
/** Checks pegin witness for validity */
|
/** Checks pegin witness for validity */
|
||||||
bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout);
|
bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout, bool check_depth = true);
|
||||||
/** Extracts an output from pegin witness for evaluation as a normal output */
|
/** Extracts an output from pegin witness for evaluation as a normal output */
|
||||||
CTxOut GetPeginOutputFromWitness(const CScriptWitness& pegin_witness);
|
CTxOut GetPeginOutputFromWitness(const CScriptWitness& pegin_witness);
|
||||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||||
|
|
|
||||||
|
|
@ -3662,9 +3662,7 @@ UniValue createrawpegin(const JSONRPCRequest& request)
|
||||||
|
|
||||||
// Peg-in witness isn't valid, even though the block header is(without depth check)
|
// Peg-in witness isn't valid, even though the block header is(without depth check)
|
||||||
// We re-check depth before returning with more descriptive result
|
// We re-check depth before returning with more descriptive result
|
||||||
if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN) &&
|
if (!IsValidPeginWitness(pegin_witness, mtx.vin[0].prevout, false)) {
|
||||||
!IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), 0) &&
|
|
||||||
!IsValidPeginWitness(pegin_witness, mtx.vin[0].prevout)) {
|
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Constructed peg-in witness is invalid.");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Constructed peg-in witness is invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue