dart-bitcoin / bitcoin_flutter Goto Github PK
View Code? Open in Web Editor NEWA dart Bitcoin library for Flutter.
License: MIT License
A dart Bitcoin library for Flutter.
License: MIT License
When there is only one input, I successfully transfer,But when Multiple inputs, the transfer will fail
"error": "Error validating transaction: Error running script for input 0 referencing 040bb44e5fca0c9a7794ef92d2577bdbe34f9e55e161c6dbb08977ba5b83a128 at 1: Script was NOT verified successfully.."
this is my unspent list:
{
"address": "2My58TUaybVThTdVCA4FiGq3yvApTLQiJbi",
"total_received": 3339321,
"total_sent": 427140,
"balance": 2912181,
"unconfirmed_balance": 0,
"final_balance": 2912181,
"n_tx": 22,
"unconfirmed_n_tx": 0,
"final_n_tx": 22,
"txrefs": [
{
"tx_hash": "d5e7e8f7892442d1825f05ac17c8c3a56b4ec00b00d42a685a1bac630edcab5c",
"block_height": 1938859,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 1979000,
"ref_balance": 4912181,
"spent": false,
"confirmations": 134,
"confirmed": "2021-03-04T11:02:19Z",
"double_spend": false
},
{
"tx_hash": "50bfbe5193e01ed86135af20ee11b7a74c779e204acea235af1ad0f9ea6f9807",
"block_height": 1938850,
"tx_input_n": -1,
"tx_output_n": 0,
"value": 10000,
"ref_balance": 2933181,
"spent": false,
"confirmations": 143,
"confirmed": "2021-03-04T09:59:30Z",
"double_spend": false
},
{
"tx_hash": "cc2c197249dab3807a40a45cedfd15ad332d86958bee36d7180e324b339f3b51",
"block_height": 1938839,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 3460,
"ref_balance": 2929241,
"spent": false,
"confirmations": 154,
"confirmed": "2021-03-04T08:16:58Z",
"double_spend": false
},
{
"tx_hash": "3662c08c41a9c2a5d75a079e5a55680e3758956b91fe76f7dc89e93787a54ef8",
"block_height": 1938839,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 6700,
"ref_balance": 2935781,
"spent": false,
"confirmations": 154,
"confirmed": "2021-03-04T08:16:58Z",
"double_spend": false
},
{
"tx_hash": "d9d91e7f5509a11e83adba9a4602086ba735ebdd68e8fe7a67052e8a2f63b724",
"block_height": 1938839,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 3900,
"ref_balance": 2939081,
"spent": false,
"confirmations": 154,
"confirmed": "2021-03-04T08:16:58Z",
"double_spend": false
},
{
"tx_hash": "040bb44e5fca0c9a7794ef92d2577bdbe34f9e55e161c6dbb08977ba5b83a128",
"block_height": 1938687,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 783489,
"ref_balance": 1716810,
"spent": false,
"confirmations": 306,
"confirmed": "2021-03-03T09:34:12Z",
"double_spend": false
},
{
"tx_hash": "06a6f827a5a22dbdf9a283c9fa72e0e45c0c905376cd903201a3f3f7b2864100",
"block_height": 1938684,
"tx_input_n": -1,
"tx_output_n": 1,
"value": 125632,
"ref_balance": 1084353,
"spent": false,
"confirmations": 309,
"confirmed": "2021-03-03T09:00:06Z",
"double_spend": false
}
],
"tx_url": "https://api.blockcypher.com/v1/btc/test3/txs/"
}
This is my code,Can you help me??
for (var item in unspentList) {
txb.addInput(item.tx_hash, item.tx_output_n);
totalAmount += item.value;
if (totalAmount >= outAmount + fee) {
break;
}
}
txb.addOutput(toAddress, outAmount);
if (totalAmount > outAmount + fee) {
txb.addOutput(fromAddress, totalAmount - outAmount - fee);
}
for (int index = 0; index < txb.inputs.length; index++) {
txb.sign(vin: index, keyPair: p2shPair, redeemScript: p2wpkh.output, witnessValue: totalAmount);
}
print("${txb.build().toHex()}");
Currently It seems that it's not possible to send a transaction to Segwit and Bech32 address.
Only Base58 addresses seem to work.
Is it possible to use this library to validate base58 addresses? Will there be segwit support as well?
Running the following code gives me an error that reads: 'Invalid checksum'. Code below:
var x = Address.addressToOutputScript("bc1qe43dk6yptz2e5aamxfc4sp33s6ga4v4xcrzhyv");
Does anyone know what this is?
dependencies:
flutter:
sdk: flutter
web3dart: ^2.3.1
bip39: ^1.0.6
bitcoin_flutter: ^2.0.2
Running "flutter pub get" in t_wallet...
Because every version of bitcoin_flutter depends on hex ^0.1.2 and bip39 1.0.6 depends on hex ^0.2.0, bitcoin_flutter is incompatible with bip39 1.0.6.
And because no versions of bip39 match >1.0.6 <2.0.0, bitcoin_flutter is incompatible with bip39 ^1.0.6.
So, because t_wallet depends on both bip39 ^1.0.6 and bitcoin_flutter ^2.0.2, version solving failed.
pub get failed (1; So, because t_wallet depends on both bip39 ^1.0.6 and bitcoin_flutter ^2.0.2, version solving failed.)
Process finished with exit code 1
Hello I am Trying to create a Transaction , but i always get the error Invalid version or Network mismatch i am using testnet adresses this is my log..
Bitcoin Adress moZ3hBUMbu5pFaodrsLCKg76U53NdmDVqc
Bitcoin Second Address muYEstcvt7ZyLUv6DRXNX592NF7RGSUEAo
Unhandled exception:
Invalid argument(s): Invalid version or Network mismatch
#0 P2PKH._getDataFromAddress (package:bitcoin_flutter/src/payments/p2pkh.dart:87:7)
#1 P2PKH._init (package:bitcoin_flutter/src/payments/p2pkh.dart:22:7)
#2 new P2PKH (package:bitcoin_flutter/src/payments/p2pkh.dart:18:5)
#3 addressToOutputScript (package:bitcoin_flutter/src/transaction_builder.dart:286:11)
#4 TransactionBuilder.addOutput (package:bitcoin_flutter/src/transaction_builder.dart:71:22)
#5 CreateWallet.generateTransaction (file:///home/safouene/crypto_test/main.dart:152:11)
#6 main (file:///home/safouene/crypto_test/main.dart:178:8)
#7 _startIsolate. (dart:isolate-patch/isolate_patch.dart:307:19)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
For Random.nextInt(int max)
, max
is exclusive (https://api.dart.dev/stable/2.14.4/dart-math/Random/nextInt.html). This means the _randomBytes()
function (https://github.com/dart-bitcoin/bitcoin_flutter/blob/master/lib/src/ecpair.dart#L92) does not include 255. _SIZE_BYTE
should be 256.
Hi, guys.
Do you have plans to migrate this project to null-safety?
If Yes, I wonder when it will be possible.
Thank you.
I am having issue while pushing my transaction to the blockchain the issue I get while doing so is
{"error": "Error validating transaction: witness script detected in tx without witness data."}
can someone provide a proper method
For example, let's assume I want to generate addresses under the following BIP84 (BIP44 for native segwit) derivation paths:
m / 84' / 0' / 0' / 0 / 0
m / 84' / 0' / 0' / 1 / 0
And let's suppose that all I have is the wallet mnemonic. I know that I can get to the node by using the following (i think):
final seed = bip39.mnemonicToSeed(await secureStore.read(key: 'mnemonic'));
final root = bip32.BIP32.fromSeed(seed);
final node = root.derivePath("m/84'/0'/0'/0/0");
You can assume that the secureStore read call always returns a valid mnemonic. How do I generate a native segwit address from what I have using this library?
Thanks once again
bs58check could be updated to 1.0.2 and hex could be upgraded to 0.2.0, would those latest versions cause any breaking changes?
bip32: ^2.0.0
bitcoin_flutter: ^2.0.2
Running "flutter pub get" in xxx...
Because bitcoin_flutter >=0.0.5 depends on bip32 ^1.0.5 and xxx depends on bip32 2.0.0, bitcoin_flutter >=0.0.5 is forbidden.
So, because xxx depends on bitcoin_flutter 2.0.2, version solving failed.
pub get failed (1; So, because xxx depends on bitcoin_flutter 2.0.2, version solving failed.)
Process finished with exit code 1
can I broadcast a Transaction to the Bitcoin network if I use this plugin
Hey, I noticed that you guys recently added P2WPKH support which is fantastic. The problem is that the library has not been updated on pub.dev so I can't really use these features.
Here is the link: https://pub.dev/packages/bitcoin_flutter/versions
As you can see in the 'Versions' tab, the last time this package was officially updated on pub.dev was Apr 21, 2019.
That's all. :)
I may be doing something wrong here, but I have a test wherein I generate a wallet and use it's private key to sign a transaction (inspired by https://github.com/dart-bitcoin/bitcoin_flutter/blob/master/test/integration/transactions_test.dart#L11)
So here's how it looks: (this is just testnet so I'm going to post the keys here too)
import 'dart:convert';
import 'dart:typed_data';
import 'package:test/test.dart';
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
import 'package:raven/account.dart';
import 'package:bip39/bip39.dart' as bip39;
main() {
test('bitcoinjs-lib (transactions) can create a 1-to-1 Transaction', () {
...
final alice =
ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
print(alice.privateKey);
print(Uint8List.fromList(node.wallet.privKey.codeUnits));
print(node.wallet.privKey);
final pair = ECPair(Uint8List.fromList(node.wallet.privKey.codeUnits),
Uint8List.fromList(node.wallet.pubKey.codeUnits),
network: node.params.network, compressed: true);
final txb = TransactionBuilder(network: node.params.network);
txb.setVersion(1);
txb.addInput(
'56fcc747b8067133a3dc8907565fa1b31e452c98b3f200687cb836f98c3c46ae',
1);
txb.addOutput('mp4dJLeLDNi4B9vZs46nEtM478cUvmx4m7', 4000000);
txb.sign(vin: 0, keyPair: pair);
});
}
Now when I run this test I get an error on the last line:
Invalid argument(s): Expected Private
package:bip32/src/utils/ecurve.dart 134:22 sign
package:bitcoin_flutter/src/ecpair.dart 33:12 ECPair.sign
package:bitcoin_flutter/src/transaction_builder.dart 201:33 TransactionBuilder.sign
test\raven_tx_send_test.dart 37:9 main.<fn>
and the print outs for the keys are:
alice.privateKey:
[140, 17, 44, 246, 40, 54, 46, 207, 77, 72, 47, 104, 175, 45, 187, 80, 200, 162, 203, 144, 210, 38, 33, 93, 233, 37, 65, 122, 169, 51, 106, 72]
Uint8List.fromList(node.wallet.privKey.codeUnits):
[102, 49, 56, 100, 98, 101, 57, 57, 101, 98, 57, 101, 102, 99, 50, 56, 100, 57, 99, 52, 97, 50, 57, 97, 53, 48, 100, 56, 57, 54, 48, 99, 97, 55, 57, 54, 48, 99, 99, 102, 101, 97, 48, 50, 101, 102, 57, 49, 98, 101, 52, 98, 102, 50, 49, 98, 49, 49, 98, 97, 101, 50, 49, 97]
node.wallet.privKey:
f18dbe99eb9efc28d9c4a29a50d8960ca7960ccfea02ef91be4bf21b11bae21a
Notice the privKey on he HDwallet is much longer than the alice privateKey from the WIF in the example.
That difference in length causes the error because when it checks to see if it's a private key in the ecurve.dart it fails:
bool isPrivate(Uint8List x) {
if (!isScalar(x)) return false;
return _compare(x, ZERO32) > 0 && // > 0
_compare(x, EC_GROUP_ORDER) < 0; // < G
}
The length is actually 64 in this case. I'm wondering what to do here. Is the IsPrivate function mistaken? am I converting it to a Uint8List in the wrong way? Is there a way to convert the HDwallet privatekey to the same format as the WIF? would that cause problems? Like I said I don't know if it's a problem in the code or if I just don't understand something, thank you.
PS. I'm using a different network as well:
final ravencoinTestnet = NetworkParams(
name: 'Ravencoin Testnet',
testnet: true,
network: NetworkType(
messagePrefix: '\x16Raven Signed Message:\n',
bech32: 'tr',
bip32: Bip32Type(public: 0x043587cf, private: 0x04358394),
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef),
derivationBase: "m/44'/175'/1'");
Is this library still in active development? It seems like the closest thing we have to a proper bitcoin package and I'm wondering whether or not to use it for my app.
If not, does anyone have any suggestions to alternatives? Would platform channels to native btc libraries written in kotlin/swift be a feasible route to take?
Was wondering if this library is still being worked on? Seems to be a little quiet in the repo
I'm trying to spend a generated UTXO in this way:
final keyPair = ECPair.fromWIF(wif, network: regtest);
var p2pk = new P2PK(
data: new PaymentData(pubkey: keyPair.publicKey),
network: regtest)
.data;
final txb = new TransactionBuilder(network: regtest);
txb.setVersion(1);
txb.addInput(
input.id,
input.outputIndex,
null,
p2pk.output
);
// ..... addOutput and sign
After broadcasting I'm getting an error mandatory-script-verify-flag-failed (Signature is found in scriptCode) (code 16)
If it is possible can you provide an example how to do this ?
new HDWallet(seed) is not work. It need other arguments.
I noticed that in the transaction building example for P2WPKH inputs, you put the following code:
test('can create (and broadcast via 3PBP) a Transaction, w/ a P2WPKH input', () {
final alice = ECPair.fromWIF('cUNfunNKXNNJDvUvsjxz5tznMR6ob1g5K6oa4WGbegoQD3eqf4am', network: NETWORKS.testnet);
final p2wpkh = new P2WPKH(data: new PaymentData(pubkey: alice.publicKey), network: NETWORKS.testnet).data;
final txb = new TransactionBuilder(network: NETWORKS.testnet);
txb.setVersion(1);
txb.addInput('53676626f5042d42e15313492ab7e708b87559dc0a8c74b7140057af51a2ed5b', 0, null, p2wpkh.output); // Alice's previous transaction output, has 200000 satoshis
txb.addOutput("tb1qchsmnkk5c8wsjg8vxecmsntynpmkxme0yvh2yt", 1000000);
txb.addOutput("tb1qn40fftdp6z2lvzmsz4s0gyks3gq86y2e8svgap", 8995000);
txb.sign(vin: 0, keyPair: alice, witnessValue: 10000000);
// // prepare for broadcast to the Bitcoin network, see "can broadcast a Transaction" below
expect(txb.build().toHex(), '010000000001015beda251af570014b7748c0adc5975b808e7b72a491353e1422d04f5266667530000000000ffffffff0240420f0000000000160014c5e1b9dad4c1dd0920ec3671b84d649877636f2fb8408900000000001600149d5e94ada1d095f60b701560f412d08a007d11590247304402203c4670ff81d352924af311552e0379861268bebb2222eeb0e66b3cdd1d4345b60220585b57982d958208cdd52f4ead4ecb86cfa9ff7740c2f6933e77135f1cc4c58f012102f9f43a191c6031a5ffae27c5f9911218e78857923284ac1154abc2cc008544b200000000');
});
I have a question specifically about this part of the code:
txb.addInput('53676626f5042d42e15313492ab7e708b87559dc0a8c74b7140057af51a2ed5b', 0, null, p2wpkh.output); // Alice's previous transaction output, has 200000 satoshis
I know that the first parameter is the transactionID, the second represents the output that we want to spend from the transaction. But what are the third and fourth parameters? They just say null
and I don't know what the 4th refers to exactly. Can anyone help me clarify what that is?
I would also like to know what witnessValue
refers to exactly. Is it just the value of the output we're trying to spend?
We’re currently working on this Repos, so this one has been updated to Dart 3.
Please check our repos: nexm_bitcoin_flutter
After a lot of stress and changes i found out how to build a Transacation however I cannot broadcast it here is my full Code
import 'dart:typed_data';
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
import 'package:hex/hex.dart';
import "package:ed25519_hd_key/ed25519_hd_key.dart";
import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
import 'dart:convert';
import 'package:ethereum_util/ethereum_util.dart' as ethUtil;
import 'package:bs58check/bs58check.dart' as bs58check;
import 'package:web3dart/web3dart.dart';
//import 'package:base32/base32.dart';
import 'apiprovider.dart';
import 'package:bitcoin_flutter/bitcoin_flutter.dart' ;
import 'package:bip32/src/utils/wif.dart' as wif;
class CreateWallet {
Uint8List privateKey;
String getIndexAndAddressPrefix(String coinType) {
switch (coinType.toLowerCase()) {
case "btc":
return jsonEncode({'index': 0, 'addressPrefix': 0x00});
case "tbtc":
return jsonEncode({'index': 0, 'addressPrefix': 0x6f});
case "dash":
return jsonEncode({'index': 5, 'addressPrefix': 0x4c});
case "tdash":
return jsonEncode({'index': 5, 'addressPrefix': 0x8c});
case "eth":
return jsonEncode({'index': 60, 'addressPrefix': 0x04});
default:
return null;
}
}
generateWallet(String coinType) {
if (getIndexAndAddressPrefix(coinType) == null) {
print(('Please Specify Your coin type'));
} else {
var coin = jsonDecode(getIndexAndAddressPrefix(coinType));
print(coin['addressPrefix'].runtimeType);
var mnemonic = bip39.generateMnemonic();
print(mnemonic);
var seed = bip39.mnemonicToSeed(mnemonic);
var network = bip32.NetworkType(bip32: bip32.Bip32Type(private: testnet.bip32.private,public: testnet.bip32.public),wif: testnet.wif);
final node = bip32.BIP32.fromSeed(seed,network);
final WIF = node.toWIF();
print("Adresse WIF ${WIF}");
KeyData root =
ED25519_HD_KEY.getMasterKeyFromSeed(HEX.encode(seed).toString());
var xprv = root.key;
print("Master Key ${HEX.encode(xprv)}");
KeyData addrnode = ED25519_HD_KEY.derivePath(
"m/0'/2147483647'", HEX.encode(seed).toString());
this.privateKey = addrnode.key;
var step1 = ED25519_HD_KEY.getBublickKey(addrnode.key);
print("Step 1 ${HEX.encode(step1)}");
var step2 = ethUtil.sha256(step1);
print("Step 2 ${HEX.encode(step2)}");
var step3 = ethUtil.ripemd160(step2);
print("Step 3 ${HEX.encode(step3)}");
List<int> ls = new List();
ls.add(coin['addressPrefix']);
ls.addAll(step3);
var step4 = Uint8List.fromList(ls);
print("step4 ${step4}");
var step5 = bs58check.encode(step4);
print("step 5 ${step5}");
}
}
String generateAddress(coinType, seed, addressNumber) {
String response = "";
String final_adress = "";
var seeding = bip39.mnemonicToSeed(seed);
var network = bip32.NetworkType(bip32: bip32.Bip32Type(private: testnet.bip32.private,public: testnet.bip32.public),wif: testnet.wif);
final node = bip32.BIP32.fromSeed(seeding,network);
final WIF = node.toWIF();
var coin = jsonDecode(getIndexAndAddressPrefix(coinType));
KeyData root =ED25519_HD_KEY.getMasterKeyFromSeed(HEX.encode(seeding).toString());
var index = coin['index'];
var path = "m/44'/${index}'/0'/0'/${addressNumber}'";
var addrnode = ED25519_HD_KEY.derivePath(path, HEX.encode(seeding).toString());
if (coin['index'] == 0 || coin['index'] == 5) {
var step1 = ED25519_HD_KEY.getBublickKey(addrnode.key);
var step2 = ethUtil.sha256(step1);
var step3 = ethUtil.ripemd160(step2);
List<int> ls = new List();
ls.add(coin['addressPrefix']);
ls.addAll(step3);
var step4 = Uint8List.fromList(ls);
var step5 = bs58check.encode(step4);
final_adress = step5;
response = jsonEncode({'WIF': WIF, 'address': final_adress});
} else if (coin['index'] == 60) {
var pubKey = ethUtil.privateKeyToPublicKey(addrnode.key);
var addr = HEX.encode(ethUtil.publicKeyToAddress(pubKey)).toString();
var adress = EthereumAddress.fromHex(addr);
final_adress = adress.toString();
response = jsonEncode({'WIF': WIF, 'address': final_adress});
}
return response;
}
createTransaction(w)
{ wif.WIF decoded = wif.decode(w);
final version = decoded.version;
print("Version ${version}");
print("network version ${testnet.wif}");
final alice = ECPair.fromWIF(w,network: testnet);
final txb = new TransactionBuilder(network: testnet);
txb.setVersion(1);
txb.addInput('86c06c5cee45505eaea0931fe7de32f6c0861cdead713271fd19ad1b67169fc8', 0); // Alice's previous transaction output, has 15000 satoshis
txb.addOutput('mtTRjb3oPBdU3GAarKr257GYoBybHTraZP', 12000);
txb.sign(0, alice) ;
final hash= txb.build().toHex();
print("transaction ${hash}");
}
}
void main() {
var wallet = CreateWallet();
var btc2 = json.decode(wallet.generateAddress(
"tbtc",
"example impact route defense more risk romance turtle candy twenty network sound",
0));
var btc = json.decode(wallet.generateAddress(
"tbtc",
"ahead scale orphan shallow curtain include aunt hamster fire leaf stand reveal",
0));
print("Bitcoin Adress ${btc['address']}");
print("Bitcoin Second Address ${btc2['address']}");
wallet.createTransaction(btc['WIF']);
}
Given this payload of transaction data
"unspentAddressOutputs": {
"8db82fe48d275647df6e01246978594dffcf8166d080a58868be51ed63dc94cf": [
{
"value": 100000,
"script": "76a9142b9bc14f739fbab340142f9e1ec800ff654e15d188ac",
"addr": "mjVXwMisfn1hv7pb1a6BuU8aaBWmyNtT3G",
"spent": false,
"type": 0,
"n": 1
}
],
"b8a654afc77292d2011c7ae79d1e2ef469add829d2f1ff4ec3d287216da9d2c1": [
{
"value": 1006,
"script": "76a9145c654954c781d522d3d965d78bc7ff5fb983b5a888ac",
"addr": "mowVoD35wRZWSueDN1UPDSdzVHZLh22gj7",
"spent": false,
"type": 0,
"n": 0
},
{
"value": 98736,
"script": "00142b9bc14f739fbab340142f9e1ec800ff654e15d1",
"spent": false,
"type": 0,
"n": 1
}
],
}
I am trying to construct a transaction using these unspent outputs but it fails on building the transaction
final TransactionBuilder txb = TransactionBuilder(network: wallet.network);
txb.addInput('8db82fe48d275647df6e01246978594dffcf8166d080a58868be51ed63dc94cf', 1);
txb.addInput('b8a654afc77292d2011c7ae79d1e2ef469add829d2f1ff4ec3d287216da9d2c1', 0);
txb.addInput('b8a654afc77292d2011c7ae79d1e2ef469add829d2f1ff4ec3d287216da9d2c1', 1); //<- think this one is P2WPKH
// total is 199742
txb.addOutput('mowVoD35wRZWSueDN1UPDSdzVHZLh22gj7', 109742);
txb.addOutput('mjVXwMisfn1hv7pb1a6BuU8aaBWmyNtT3G', 90000 - fee);
txb.sign(vin: 0, keyPair: keypair);
txb.sign(vin: 1, keyPair: keypair);
txb.sign(vin: 2, keyPair: keypair, witnessValue: 98736);
txb.build.toHex() // this throws exception 'length called on null' and that comes from transaction.dart:253
when I remove
txb.addInput('b8a654afc77292d2011c7ae79d1e2ef469add829d2f1ff4ec3d287216da9d2c1', 1); //<- think this one is P2WPKH
and just sign
txb.sign(vin: 0, keyPair: keypair);
txb.sign(vin: 1, keyPair: keypair);
I get
0100000002cf94dc63ed51be6888a580d06681cfff4d59786924016edf4756278de42fb88d010000006a473044022067fe36a90b583006c491bb4ae22b6112ebf01d98095f71c18c6f21fc4e148edc02202a4553192d3c4f17181bce74d1be5692fb37d3b0757002f3286baf8902861ce3012102b2ed1998d523265ee7b28772ac5f43753cf83ceb5cb624a8cc136830745b26b1ffffffffc1d2a96d2187d2c34efff1d229d8ad69f42e1e9de77a1c01d29272c7af54a6b8000000006b483045022100f610387f519a51e6312ce015264f896f240c5dbf3e43a2fc377c80320c510835022048ff8890ae6350121a7ee0b1f6fc159dd413b2e0b0b11cabbab7e2f79eb02d02012102b2ed1998d523265ee7b28772ac5f43753cf83ceb5cb624a8cc136830745b26b1ffffffff024c270000000000001976a9145c654954c781d522d3d965d78bc7ff5fb983b5a888acea5d0100000000001976a9142b9bc14f739fbab340142f9e1ec800ff654e15d188ac00000000
basically equal to Script failed an OP_EQUALVERIFY operation
Am I using the library wrong?
Hi,
I would like to announce the new project https://github.com/nomo-app/walletkit-dart.
walletkit-dart
has been inspired by the great work that was done by the dart-bitcoin project.
walletkit-dart
is already used in production, but the API is not yet stable and there are still some tests that are not yet opensourced.
I think we are both sharing the goal of making Flutter/Dart the best platform for developing wallets, and perhaps there exists a possibility for collaboration between the dart-bitcoin project and nomo-app.
As described above...
can you provide a example about send btc transaction?
Hey!
Thanks for the library!
I wanted to know if you already support multisig transactions, otherwise I did not find this in the documentation.
If not - are you planning it, and if yes - are there any estimate, when will you add this? :)
will you able to port copay into flutter? at least front end
please migrate the package to null safety
How to validate litecoin address
The following example:
txb.addInput(
'53676626f5042d42e15313492ab7e708b87559dc0a8c74b7140057af51a2ed5b',
0,
null,
p2wpkh
.output); // Alice's previous transaction output, has 200000 satoshis
txb.addOutput('tb1qchsmnkk5c8wsjg8vxecmsntynpmkxme0yvh2yt', 1000000);
txb.addOutput('tb1qn40fftdp6z2lvzmsz4s0gyks3gq86y2e8svgap', 8995000);
txb.sign(vin: 0, keyPair: alice, witnessValue: 10000000);
the comment says Alice is prev output is 200_000 and the outputs are 1_000_000 and 8_995_000 and witnessValue is 10_000_000.
This does not seem right.
As I understand, 1. witnessValue = total amount inputs and 2. inputs >outputs. In this example both cases fail.
The package does not generate the private key and address correctly at all
check your example into https://iancoleman.io/bip39/ on bitcoin network
I am working in Flutter App, I need this library to work generating new bitcoin adress, and make transactions.
Do you recommend work in production with this library?
Do you know some flutter app using the library in production?
Thanks.
I need to make a transaction with bitcoin_flutter is it possible to make transaction from one wallet to another and if it is is there a function to make it simply transaction(pubKey,prvtKey,amount).
Is there any other relation between the dart-bitcoin
project, other than the names matching with dart-bitcoin/bitcoin_flutter
?
https://github.com/dartcoin/dart-bitcoin
Hey,
I saw that this project is inspired by bitcoinjs.
Bitcoinjs has toOutputScript and I was wondering if there is an equivalent inside bitcoin_flutter.
I didn't find any so far.
What I'm trying to do is basically this:
let script = bitcoin.address.toOutputScript(address)
let hash = bitcoin.crypto.sha256(script)
let reversedHash = new Buffer(hash.reverse())
console.log(address, ' maps to ', reversedHash.toString('hex'))
bitcoinjs/bitcoinjs-lib#990 (comment)
I'm working with electrum and I do believe that there is no script hashing possible without this method.
Thanks
Willy
Hi, thanks for your great work on the library. Currently I do seem to get Invalid version or network mismatch error
whenever I use P2SH addresses starting with 3
. I'm able to send to legacy and native segwit addresses. Does the library support sending to P2SH addresses starting with 3
?
@RohanKapurDEV why do you wanna to export this class. Could give me a context. And export p2wpkh also if need
Originally posted by @longhoangwkm in #28 (comment)
After signing the transaction and calling the build function on TransactionBuilder. It is not broadcasting to the blockchain network. How to solve this? Please help. Do I need to perform any extra steps for broadcast?
NetworkType versacoin = new NetworkType(
messagePrefix: '\x19VersaCoin Signed Message:\n',
bech32: 'go',
bip32: new Bip32Type(public: 0x0488B21E, private: 0x0488ADE4),
pubKeyHash: 0x46, // 70 in decimal, V in prefix symbol
scriptHash: 0x05, // 5 in decimal, 3 in prefix symbol
wif: 0xc6, // 198 in decimal, 2 in prefix symbol
);
final alice = ECPair.fromWIF(privateKey, network: versacoin);
final txb = new TransactionBuilder(network: versacoin);
final p2wpkh = new P2WPKH(data: new PaymentData(pubkey: alice.publicKey), network: versacoin).data;
txb.addInput(versaCoinGetAddressResponse.lastTxs[i].addresses, 0, null, p2wpkh.output);
txb.addOutput(toAddress, 1000000);
txb.sign(vin: 0, keyPair: alice, witnessValue: 2500);
// prepare for broadcast to the Bitcoin network, see 'can broadcast a Transaction' below
String txHash = txb.build().toHex();
Hello!When is this package expected to be updated, or is there any update plan?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.