Merge #322: add better reject reason for immature peg-in, with test

20dee2e slight peg-test language fixup (Gregory Sanders)
248eb91 add better reject reason for immature peg-in, with test (Gregory Sanders)
This commit is contained in:
Gregory Sanders 2018-03-27 12:31:24 -04:00
commit 257602efc1
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB
2 changed files with 17 additions and 3 deletions

View file

@ -3660,7 +3660,11 @@ UniValue createrawpegin(const JSONRPCRequest& request)
stack.push_back(txData);
stack.push_back(txOutProofData);
if (!IsValidPeginWitness(pegin_witness, mtx.vin[0].prevout)) {
// 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
if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN) &&
!IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), 0) &&
!IsValidPeginWitness(pegin_witness, mtx.vin[0].prevout)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Constructed peg-in witness is invalid.");
}