@@ -77,6 +77,7 @@ static int AppInitRawTx(int argc, char* argv[])
77
77
strUsage += HelpMessageOpt (" in=TXID:VOUT(:SEQUENCE_NUMBER)" , _ (" Add input to TX" ));
78
78
strUsage += HelpMessageOpt (" locktime=N" , _ (" Set TX lock time to N" ));
79
79
strUsage += HelpMessageOpt (" nversion=N" , _ (" Set TX version to N" ));
80
+ strUsage += HelpMessageOpt (" rbfoptin(=N)" , _ (" Set RBF opt-in sequence number for input N (if not provided, opt-in all available inputs)" ));
80
81
strUsage += HelpMessageOpt (" outaddr=VALUE:ADDRESS" , _ (" Add address-based output to TX" ));
81
82
strUsage += HelpMessageOpt (" outpubkey=VALUE:PUBKEY[:FLAGS]" , _ (" Add pay-to-pubkey output to TX" ) + " . " +
82
83
_ (" Optionally add the \" W\" flag to produce a pay-to-witness-pubkey-hash output" ) + " . " +
@@ -202,6 +203,24 @@ static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
202
203
tx.nLockTime = (unsigned int ) newLocktime;
203
204
}
204
205
206
+ static void MutateTxRBFOptIn (CMutableTransaction& tx, const std::string& strInIdx)
207
+ {
208
+ // parse requested index
209
+ int inIdx = atoi (strInIdx);
210
+ if (inIdx < 0 || inIdx >= (int )tx.vin .size ()) {
211
+ throw std::runtime_error (" Invalid TX input index '" + strInIdx + " '" );
212
+ }
213
+
214
+ // set the nSequence to MAX_INT - 2 (= RBF opt in flag)
215
+ int cnt = 0 ;
216
+ for (CTxIn& txin : tx.vin ) {
217
+ if (strInIdx == " " || cnt == inIdx) {
218
+ txin.nSequence = std::numeric_limits<unsigned int >::max () - 2 ;
219
+ }
220
+ ++cnt;
221
+ }
222
+ }
223
+
205
224
static void MutateTxAddInput (CMutableTransaction& tx, const std::string& strInput)
206
225
{
207
226
std::vector<std::string> vStrInputParts;
@@ -649,6 +668,9 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
649
668
MutateTxVersion (tx, commandVal);
650
669
else if (command == " locktime" )
651
670
MutateTxLocktime (tx, commandVal);
671
+ else if (command == " rbfoptin" ) {
672
+ MutateTxRBFOptIn (tx, commandVal);
673
+ }
652
674
653
675
else if (command == " delin" )
654
676
MutateTxDelInput (tx, commandVal);
0 commit comments