If I set nSequence to be 0xffffffff and broadcast that transaction. Will it be considered safe as nobody can double-spend it before it's getting into the block? Thank you.
That was the faulty assumption before "
mempoolrbf" option is implemented.
"
Faulty" because even if most nodes wont accept a replacement of it by default, there's no stopping anyone to remove it from their mempool and accept the replacement instead.
It's up to Miners (
pool or solo) which transaction to include or which one to reach their node to get included to the blockchain.
If more of "
it may not be replaced" than "
it will not be replaced".
It was mainly used by centralized service to implement zero-fee deposits with low risk on their part
but since they are custodial, they are still in control of what their users can withdraw in case the unconfirmed transaction is replaced.
In your case, you mustn't assume that it's safe.
And speaking of mempoolrbf option aka "
full-rbf".
If a node enabled the setting, it will accept replacement regardless if
nSequence field of the transaction is
0xffffffff or
0xffffffff -1.
I've tested this before and I can say that it's now very easy to replace an unconfirmed transactions without opt-in-rbf flag as long a you can broadcast the replacement to nodes that accept it.
-snip-
-snip-
OP must be referring to BIP125 since
nLocktime has nothing to do with transaction replacement.
BIP-0125:
Opt-in Full Replace-by-Fee Signaling