Comments (12)
Fix merged to master. Release is tagged 0.4.1 and pushed to pub.dev.
from dartsv.
Find problem at transaction/transaction_output.dart
calcVarInt
function .
Use var tx = Transaction.fromHex(rawtx)
, seems endian
problem , try rawtx as below:
02000000014baf08d990e8788d505ab64eb64db79b2caf7a0b60aa3b8bb0754cba8e63d6a40000000000ffffffff037803000000000000535101400100015101b101b26114e75c4ed4992bebfc3b390d4f6d4374d3769f31cb005179517a7561587905626164676587695979a9517987695a795a79ac77777777777777777777776a0800000000000000000000000000000000fd3d01006a4d38017b226973737565725f6e616d65223a2231222c226973737565725f61646472657373223a22222c22636f6e746163745f64657461696c73223a2231222c2262616467655f6e616d65223a2268756c69616e67222c2262616467655f6e616d655f616262726576696174696f6e223a226875222c2262616467655f6c6f676f223a2231222c2262616467655f636f6c6f72223a2231222c2262616467655f636f766572223a2231222c2262616467655f6261636b223a2231222c227469746c65223a2231222c227375627469746c65223a2231222c226465736372697074696f6e223a2231222c226163746976655f6174223a22222c226578706972655f6174223a22222c22736d616c6c6573745f756e6974223a22222c2264656661756c745f756e6974223a22222c22756e69745f726174696f223a307d933d0f00000000001976a91499b1a932fa86282b202989091dcdd5580e7a49d888ac00000000
Then compare tx.uncheckedSerialize() == rawtx
will return false.
from dartsv.
Thanks. Investigating now.
from dartsv.
pointycastle has been handed over to bouncycastle.org and is active again. see the new PR linked above
from dartsv.
TwoStack.org has now been upgraded to use PointyCastle 2.0.x. Closing issue.
from dartsv.
hi @stephanfeb , thanks for porting to pointycastle v2. however, i think the issue is not solved since the PR mentioned above has still not been merged? I ran the test @Dhuliang provided and that seems to still fail. However, I might fail to grasp the details :)
from dartsv.
The issue with calcVarInt is unrelated to the Bitcoin Signed Messages issue reported. The Signed Messages were affected by the encodeBigInt() function in PointyCastle. I've simply removed that dependency since the BigInt encoding is two's-complement and the requirement for Signature is just to convert the hex buffer being signed to a BigInt.
The calcVarInt issue reported by @Dhuliang happens when his provided "rawTX" is serialized and then deserialized. I've double-checked all my VarInt code. There are more than 1000 serialization/deserialization test vectors which run flawlessly with current VarInt calculations.
My suspicion is that the provided "rawTX" is malformed, and that my library serializes it correctly. @Dhuliang can you open a separate issue with more information e.g. what the source of the "rawTX" is, and how you created it ?
from dartsv.
thanks for explaining @stephanfeb !
btw, I also tested with a recent raw transaction and that test succeeded.
from dartsv.
Oh cool. Btw I've just release 0.4.0
to pub.dev. Please raise any issues you might encounter.
Cheers
Stephan
from dartsv.
TwoStack.org has now been upgraded to use PointyCastle 2.0.x. Closing issue.
Sorry to inform you but the issue has not been resolved by upgrading to use the new PointyCastle
Bad signatures still happen sometimes, here is an example so you can test yourself:
import 'dart:convert';
import 'package:dartsv/src/message.dart';
import 'package:dartsv/src/privatekey.dart';
void main() {
String message = '/ipfs/QmdwwGaAujZ2gkPPAfQZJ9jUKRBB7d67ttD6phwU8BmfGS';
String wifKey = 'L4TAY9FYkGzwnZ77WRXZzYXsViKjVN31LzNenYfLLrEiFxoZbmSn';
SVPrivateKey privateKey = SVPrivateKey.fromWIF(wifKey);
Message messageSigner = Message(Utf8Codec().encode(message));
String signature = messageSigner.sign(privateKey);
print(signature);
if (base64Decode(signature).length != 65) {
print('BAD SIGNATURE!!');
}
}
BAD signature: 'H5W9/hDsIu5DjlWtSYcHFQnuhZ+MKWJTF+5bm+KVwA4hy0ehn1AMLjlAMEVT6hLjKuNirrKUW6bJsxGFG06yYw=='
(notice the double == at the end)
GOOD signature should be:
'HwCVvf4Q7CLuQ45VrUmHBxUJ7oWfjCliUxfuW5vilcAOIctHoZ9QDC45QDBFU+oS4yrjYq6ylFumybMRhRtOsmM='
see my original comment on how to fix it.
from dartsv.
Thanks for the example code @WouterGlorieux . I've just merged a fix to master.
Can you have a go and see if this resolves your problem ? If yes I'll prepare a release.
from dartsv.
Thank you for the quick response @stephanfeb
Yes, this fix does resolve the problem.
from dartsv.
Related Issues (13)
- SVScript.fromString doesn't work correctly HOT 5
- transaction sign failed HOT 1
- The integer literal 0xFFFFFFFFFFFFFFFF can't be represented exactly in JavaScript. HOT 1
- Generate an address and send and receive Bitcoin HOT 1
- Invalid WIF generation HOT 2
- Bitindex.network is returning 502 HOT 1
- How to derive three different types of BTC addresses from mnemonics or private key HOT 1
- Is this package use for connect to all types of bitcoin blockhain? HOT 1
- Unsupported operation: Isolate.resolvePackageUri HOT 2
- Error HOT 2
- support stas token transfer HOT 2
- error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dartsv.