Closed bazooka70 closed 6 years ago
If I'm reading the docs correctly SigHash
should be added another flag FORKID
== 64 (0x40)
Then var tx = builder.BuildTransaction(true, ALL|FORKID);
should work. still checking into it...
I don't think so, I think the signature process is quite different. I probably need to refactor NBitcoin to allow Network specific signature schemes.
I was quite sure there should be another flag FORKID
.
https://bitcoin.stackexchange.com/questions/58012/what-is-the-exact-difference-between-a-bitcoin-and-bitcoin-cash-raw-transaction/58030#58030
I added this flag to enum SigHash
and tested it via:
tx = builder.BuildTransaction(true, sigHash, SigHash.All | SigHash.Forkid);
and obviously TransactionBuilder
told me Script error on input 0 (SigHashType)
.
Sorry, but I know very little about this issue. :/
yeah I probably know why
trying to work on a simple solution
Did you have any luck with this issue?
Yes, I started refactoring to make it possible, but still some things to do.
Closing this one.
Basically you need to call TransactionBuilder.SetConsensusFactory(network)
and it will sign correctly without you having to change your code.
Will update the references soon.
Done, have fun.
Wow! thanks! I will run some tests asap.
BTW,
Basically you need to call TransactionBuilder.SetConsensusFactory(network) ...
Shouldn't the TransactionBuilder
always call SetConsensusFactory
for any network?
I have installed the latest NuGet packages.
TransactionBuilder.Verify()
returns false and error:
Script error on input 0 (SigHashType)
My code:
...
builder.SendEstimatedFees(feeRate);
builder.SetConsensusFactory(network);
Transaction tx = builder.BuildTransaction(true); // build and sign the transaction
NBitcoin.Policy.TransactionPolicyError[] errors;
bool builderVerify = builder.Verify(tx, out errors);
if (!builderVerify)
{
Console.WriteLine($"Error builderVerify!");
foreach (var e in errors)
{
Console.WriteLine("builder error-> " + e.ToString());
}
Console.ReadKey();
return;
}
// broadcast Tx
...
I will double check gain...
OK, I double checked.
The builder.Verify
returns false and an error as described above, but the transaction Broadcast
is successful.
Thanks a lot v4.1.1.3 on its way.
updated, it works now
Great news! thanks. can you please answer my question:
Shouldn't the TransactionBuilder
by default, always call SetConsensusFactory()
for any network (also for BTC)?
Is there any reason why we need to explicitly call SetConsensusFactory
?
Because if I don't know the specific network you are signing, I can't know which algorithm to use to sign properly.
Ok, I had the assumption TransactionBuilder
knows about the network at some point of the build...
This fails with:
Please, what could cause this, and how can I resolve this?
The same issue is true with BTG network.
Related: https://github.com/dgarage/NBXplorer/pull/50