Coin selection requires knowing the weight of a transaction so that fees
can be estimated. However for external inputs, the weight may not be
avialble, and solving data may not be enough as the input could be one
that we do not support. By allowing users to specify input weights,
those external inputs can be included in the transaction.
Additionally, if the weight for an input is specified, that value will
always be used, regardless of whether the input is in the wallet or
solving data is available. This allows us to account for scenarios where
the wallet may be more conservative and estimate a larger input than may
actually be created.
For example, we assume the maximum DER signature size, but an external
input may be signed by a wallet which does nonce grinding in order to get
a smaller signature. In that case, the user can specify the smaller
input weight to avoid overpaying transaction fees.
throwJSONRPCError(RPC_INVALID_PARAMETER,"Invalid parameter, weight cannot be less than 165 (41 bytes (size of outpoint + sequence + empty scriptSig)*4(witnessscalingfactor))+1(emptywitness)");
}
if(weight>MAX_STANDARD_TX_WEIGHT){
throwJSONRPCError(RPC_INVALID_PARAMETER,strprintf("Invalid parameter, weight cannot be greater than the maximum standard tx weight of %d",MAX_STANDARD_TX_WEIGHT));
{"sequence",RPCArg::Type::NUM,RPCArg::DefaultHint{"depends on the value of the 'locktime' and 'options.replaceable' arguments"},"The sequence number"},
{"weight",RPCArg::Type::NUM,RPCArg::DefaultHint{"Calculated from wallet and solving data"},"The maximum weight for this input, "
"including the weight of the outpoint and sequence number. "
"Note that signature sizes are not guaranteed to be consistent, "
"so the maximum DER signatures size of 73 bytes should be used when considering ECDSA signatures."
"Remember to convert serialized sizes to weight units when necessary."},