Bitcoin’s Time Locks. Bitcoin, having no discernible ...

Locktime: Use Bitcoin script to its fullest potential.

https://hedgetrade.com/what-is-locktime/
Did you know you can set time parameters on your Bitcoin transactions? I have written I brief explanation of it here.
submitted by CryptoEK to Bitcoin [link] [comments]

LockTime - nLockTime /r/Bitcoin

LockTime - nLockTime /Bitcoin submitted by SimilarAdvantage to BitcoinAll [link] [comments]

[bitcoin-dev] [BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime

submitted by ciphera to Bitcoin [link] [comments]

Will this locktime tx ever become valid? /r/Bitcoin

Will this locktime tx ever become valid? /Bitcoin submitted by BitcoinAllBot to BitcoinAll [link] [comments]

How to create a locktime based transaction /r/Bitcoin

How to create a locktime based transaction /Bitcoin submitted by BitcoinAllBot to BitcoinAll [link] [comments]

Spending an OP_HODL (CheckLockTimeVerify) address with Electrum.

I've been playing around with OP_CHECKLOCKTIMEVERIFY (op_hodl) for the last few weeks since I haven't found it easy to do in many wallets. Eariler I posted on using the CoinBin wallet interface (locally) to do it, and before that I posted a P2WSH bitcoinlib script to do it.
Today I finally sat down and wrote a script using only Electrum's API. You can run it as any Python script by having Electrum installed from source. Or if you're cavalier (and crazy) you can run it directly from the electrum console with the following command, assuming you put the script in C:\temp.
with open(r"C:\temp\elec-p2sh-hodl.py", 'r') as s: exec(s.read())
It should be noted, that one should NEVER do this, since it is effectively giving me control of your Electrum wallet (bad). It is coded to testnet if that is any consolation.
The script is designed to recreate TXN a8110...adc93, but with Electrum 4.0.4, the R-value grinding causes the signature size to differ, causing signature malleability. Apparently CoinBin and bitcoinlib haven't followed Core when they made this change in 0.17.0. The TXN is still valid, just with a different hash.
If you want to spend a different OP_HODL address, you can hopefully see the simple fields required to change.
References: * The new Electrum OP_HODL spend P2SH script * The bitcoinlib OP_HODL spend P2SH script * The bitcoinlib OP_HODL spend P2WSH script * Thread detailing how to spend a P2SH OP_HODL address in CoinBin * Thread initially discussing OP_HODL in general * The original PR to standardize R-value grinding in Bitcoin Core * Thread discussing my surprise at signature malleability * Request to implement R-value grinding in bitcoinlib
submitted by brianddk to Bitcoin [link] [comments]

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime | Btc Drak | Aug 13 2015 /r/bitcoin_devlist

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime | Btc Drak | Aug 13 2015 /bitcoin_devlist submitted by BitcoinAllBot to BitcoinAll [link] [comments]

BIP 68 (Relative Locktime) bug | Tom Harding | Jul 05 2015 /r/bitcoin_devlist

BIP 68 (Relative Locktime) bug | Tom Harding | Jul 05 2015 /bitcoin_devlist submitted by BitcoinAllBot to BitcoinAll [link] [comments]

Bitcoin locktime issue

How can I create a transaction using the command createrawtransaction but specifying a locktime?
submitted by RIP-Department to Bitcoin [link] [comments]

Power of the Command Line (bitcoin-cli, hwi, electrum, trezorctl)

I think some of the console tools available with HW wallets today are greatly under utilized. Here's a quick write-up on how to create and sign a TXN very similar to 43d27...1fc06 found on the SLIP-14 wallet. I'll be using TrezorCTL, Electrum, and HWI for the signing. I won't go much into the setup or install, but feel free to ask if you have questions about it. Note, you don't have to use all three of these. Any one will produce a valid signed TXN for broadcast. I just showed how to do it three ways. Whats more some of the Electrum and HWI steps are interchangeable.
ColdCard also has a utility called ckcc that will do the sign operation instead of HWI, but in many ways they are interchangeable. KeepKey and Ledger both have libraries for scripted signing but no one-shot, one-line console apps that I know of. But HWI and Electrum of course work on all four.

TrezorCTL

This is the what most would think of to use to craft and sign TXNs, and is definitely very simple. The signing uses a script called build_tx.py to create a JSON file that is then used by the btc sign-tx command. The whole process is basically:
  1. tools/build_tx.py | trezorctl btc sign-tx -
This just means, take the output of build_tx and sign it. To copy 43d27...1fc06, I wrote a small script to feed build_tx, so my process looks like:
  1. ~/input.sh | tools/build_tx.py | trezorctl btc sign-tx -
But it's all very simple. Note... I used TrezorCTL v0.12.2 but build_tx.py version 0.13.0 1.

input.sh

```

!/bin/bash

secho() { sleep 1; echo $*}
secho "Testnet" # coin name secho "tbtc1.trezor.io" # blockbook server and outpoint (below) secho "e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00:0" secho "m/84'/1'/0'/0/0" # prev_out derivation to signing key secho "4294967293" # Sequence for RBF; hex(-3) secho "segwit" # Signature type on prev_out to use secho "" # NACK to progress to outs secho "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3" # out[0].addr secho "10000000" # out[1].amt secho "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu" # out[1].addr secho "20000000" # out[1].amt secho "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x" # out[2].addr secho "99999694" # out[2].amt secho "" # NACK to progress to change secho "" # NACK to skip change secho "2" # txn.version secho "0" # txn.locktime ```

Electrum

Electrum is one of the better GUI wallets available, but it also has a pretty good console interface. Like before you need your Trezor with the SLIP-14 wallet loaded and paired to Electrum. I'll assume Electrum is up and running with the Trezor wallet loaded to make things simple.
Like with TrezorCTL, Electrum feeds on a JSON file, but unlike TrezorCTL it needs that JSON squished into the command line. This is a simple sed command, but I won't bore you with the details, but just assume that's done. So the process in Electrum (v4.0.3) looks like:
  1. electrum serialize (create psbt to sign)
  2. electrum --wallet signtransaction (sign said psbt)
Still pretty simple right! Below is the JSON I smushed for #1

txn.json

{ "inputs": [{ "prevout_hash":"e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00", "prevout_n": 0, "value_sats": 129999867 }], "outputs": [{ "address": "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3", "value_sats": 10000000 },{ "address": "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu", "value_sats": 20000000 },{ "address": "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x", "value_sats": 99999694 }]}

HWI

HWI is an unsung hero in my book. It's a very small clean and simple interface between HW wallets and Bitcoin Core. It currently supports a good range of HW wallets. It keeps itself narrowly focused on TXN signing and offloads most everything else to Bitcoin Core. Again, I'll assume you've imported your Trezor keypool into Core and done the requisite IBD and rescan. And if you don't have the RPC enabled, you can always clone these commands into the QT-console.
To sign our TXN in HWI (v1.1.2), we will first need to craft (and finalize) it in Bitcoin Core (0.21.1). Like in Electrum, we will have to use simple sed to smush some JSON into command arguments, but I'll assume you have that covered. It will take an inputs.json and an outputs.json named separately.
  1. bitcoin-cli createpsbt (create psbt)
  2. bitcoin-cli -rpcwallet= walletprocesspsbt (process psbt)
  3. hwi -f signtx (sign psbt)
  4. bitcoin-cli -rpcwallet= finalizepsbt (get a signed TXN from psbt)
A little more involved, but still nothing too bad. Plus this gives you the full power of Bitcoin Core including integrations with LND (lightning).

inputs.json

[{ "txid": "e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00", "vout": 0 }]

outputs.json

[{ "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3": 0.10000000 },{ "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu": 0.20000000 },{ "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x": 0.99999694 }]

Conclusion

This may all seem like very low level coding, but is surprisingly simple once you get a knack for it. Whats more, all these platforms support testnet which allows you to practice with valueless coins until you get the hang of it. And, like many things in bitcoin, this is all (mostly) python, which is one of the easier languages to learn.
Enjoy
Footnotes
1 - https://github.com/trezotrezor-firmware/issues/1296
submitted by brianddk to Bitcoin [link] [comments]

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime (Btc Drak) | Nicolas Dorier | Aug 13 2015 /r/bitcoin_devlist

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime (Btc Drak) | Nicolas Dorier | Aug 13 2015 /bitcoin_devlist submitted by BitcoinAllBot to BitcoinAll [link] [comments]

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime | Btc Drak | Sep 16 2015 /r/bitcoin_devlist

[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime | Btc Drak | Sep 16 2015 /bitcoin_devlist submitted by BitcoinAllBot to BitcoinAll [link] [comments]

Power of the Command Line (bitcoin-cli, hwi, electrum, trezorctl)

I think some of the console tools available with HW wallets today are greatly under utilized. Here's a quick write-up on how to create and sign a TXN very similar to 43d27...1fc06 found on the SLIP-14 wallet. I'll be using TrezorCTL, Electrum, and HWI for the signing. I won't go much into the setup or install, but feel free to ask if you have questions about it. Note, you don't have to use all three of these. Any one will produce a valid signed TXN for broadcast. I just showed how to do it three ways. Whats more some of the Electrum and HWI steps are interchangeable.

TrezorCTL

This is the what most would think of to use to craft and sign TXNs, and is definitely very simple. The signing uses a script called build_tx.py to create a JSON file that is then used by the btc sign-tx command. The whole process is basically:
  1. tools/build_tx.py | trezorctl btc sign-tx -
This just means, take the output of build_tx and sign it. To copy 43d27...1fc06, I wrote a small script to feed build_tx, so my process looks like:
  1. ~/input.sh | tools/build_tx.py | trezorctl btc sign-tx -
But it's all very simple. Note... I used TrezorCTL v0.12.2 but build_tx.py version 0.13.0 1.

input.sh

```

!/bin/bash

secho() { sleep 1; echo $*}
secho "Testnet" # coin name secho "tbtc1.trezor.io" # blockbook server and outpoint (below) secho "e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00:0" secho "m/84'/1'/0'/0/0" # prev_out derivation to signing key secho "4294967293" # Sequence for RBF; hex(-3) secho "segwit" # Signature type on prev_out to use secho "" # NACK to progress to outs secho "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3" # out[0].addr secho "10000000" # out[1].amt secho "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu" # out[1].addr secho "20000000" # out[1].amt secho "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x" # out[2].addr secho "99999694" # out[2].amt secho "" # NACK to progress to change secho "" # NACK to skip change secho "2" # txn.version secho "0" # txn.locktime ```

Electrum

Electrum is one of the better GUI wallets available, but it also has a pretty good console interface. Like before you need your Trezor with the SLIP-14 wallet loaded and paired to Electrum. I'll assume Electrum is up and running with the Trezor wallet loaded to make things simple.
Like with TrezorCTL, Electrum feeds on a JSON file, but unlike TrezorCTL it needs that JSON squished into the command line. This is a simple sed command, but I won't bore you with the details, but just assume that's done. So the process in Electrum (v4.0.3) looks like:
  1. electrum serialize (create psbt to sign)
  2. electrum --wallet signtransaction (sign said psbt)
Still pretty simple right! Below is the JSON I smushed for #1

txn.json

{ "inputs": [{ "prevout_hash":"e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00", "prevout_n": 0, "value_sats": 129999867 }], "outputs": [{ "address": "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3", "value_sats": 10000000 },{ "address": "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu", "value_sats": 20000000 },{ "address": "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x", "value_sats": 99999694 }]}

HWI

HWI is an unsung hero in my book. It's a very small clean and simple interface between HW wallets and Bitcoin Core. It currently supports a good range of HW wallets. It keeps itself narrowly focused on TXN signing and offloads most everything else to Bitcoin Core. Again, I'll assume you've imported your Trezor keypool into Core and done the requisite IBD and rescan. And if you don't have the RPC enabled, you can always clone these commands into the QT-console.
To sign our TXN in HWI (v1.1.2), we will first need to craft (and finalize) it in Bitcoin Core (0.21.1). Like in Electrum, we will have to use simple sed to smush some JSON into command arguments, but I'll assume you have that covered. It will take an inputs.json and an outputs.json named separately.
  1. bitcoin-cli createpsbt (create psbt)
  2. bitcoin-cli -rpcwallet= walletprocesspsbt (process psbt)
  3. hwi -f signtx (sign psbt)
  4. bitcoin-cli -rpcwallet= finalizepsbt (get a signed TXN from psbt)
A little more involved, but still nothing too bad. Plus this gives you the full power of Bitcoin Core including integrations with LND (lightning).

inputs.json

[{ "txid": "e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00", "vout": 0 }]

outputs.json

[{ "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3": 0.10000000 },{ "tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu": 0.20000000 },{ "tb1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt96jk9x": 0.99999694 }]

Conclusion

This may all seem like very low level coding, but is surprisingly simple once you get a knack for it. Whats more, all these platforms support testnet which allows you to practice with valueless coins until you get the hang of it. And, like many things in bitcoin, this is all (mostly) python, which is one of the easier languages to learn.
Enjoy
Footnotes
1 - https://github.com/trezotrezor-firmware/issues/1296
submitted by brianddk to TREZOR [link] [comments]

Electrum unable to sign transaction properly

I'm new to using bitcoin and I'm trying to figure out a problem I've been having trying to broadcast a transaction with Electrum. Initially I was trying to send bitcoin using Electrum's built in "send" function, but kept receiving the error "scriptpubkey." After browsing other forums and seeing issues similar to what I was having, it seemed like people were saying that it was an issue with the server I was connected to. In some cases, people had to try 15-20 different servers before finally being able to send the transaction through.
I thought this was the probable cause of my situation as well so tried about 20 different servers but to no avail. Then I read about "pushing the raw hex transaction" (not sure if I am using the right lingo here) and decided to try that. I was able to make an offline transaction with Electrum and signed it, then obtained the hex code from the .txn file that was created.
I then tried to broadcast the hex code on blockchain.com/btc/pushtx, but I am still receiving the error " Code: -26, Error: scriptpubkey."
So after doing some more research it seems that my problem now is not that there was an issue with servers in Eluctrum, but rather my transactions are not being properly signed. So now I have a signed offline transaction that seems to be improperly signed by Electrum, and I am clueless as to how to correct this.
Is there a way to "unsign" the transaction and sign it again properly? How would I even go about doing that? I fear that I now have money locked up in this faulty transaction that I may not be able to recover. I have all my passwords and everything so I am confused why Electrum would not have signed it properly. I am very new to all this so I'm sure I could be missing something essential. Any advice on how to broadcast and complete my transaction would be much appreciated.
I am running the latest version of Electrum on a Windows 10 computer.

Thanks!
Edit: Latest version of Electrum being 4.0.2
Also, I suppose it is probably helpful to see the decoded transaction here:
{ "version": 2, "locktime": 644562, "ins": [ { "n": 50, "script": { "asm": "", "hex": "" }, "sequence": 4294967293, "txid": "9bc2e9464a58f7d8017fc332f064eb4faf2773daa3251d5194bb851f07afe8c5", "witness": [ "3044022066e5aa2f97647eb34377a1937dc6b7dcad81c652a23c2a5be20e07e2b1af39cf02207bc07ac253b4480c07c4b2d8494d6b18d98a4b17c4bf057468b81d95655f4aa101", "0319a1a5408ccbf7cba4d569bd14b779ded4bbedec040ab84fd9c88d79ab7410fe" ] }, { "n": 8, "script": { "asm": "", "hex": "" }, "sequence": 4294967293, "txid": "dc4e13e07f74b51e623669e2b6f05f7e6e7fa173c07ffcea73b9e84462e6e3c6", "witness": [ "3044022027822d6a6531fa3a4c2b3edfc189afdfad985ade643ebb208eb15174779400b102201db77e06d6158639ae320be5123a3effc00dff48eddf17c03c699334ea58d25a01", "031399274350b7f4888cc34ca1fa1fd915d8e90222026fc89c2d5d42574e0cf7eb" ] } ], "outs": [ { "script": { "addresses": [], "asm": "039135a7d4a9df8a21977f0765ea5667e931be9d1e1f7666d1e264ef539c2c2157", "hex": "21039135a7d4a9df8a21977f0765ea5667e931be9d1e1f7666d1e264ef539c2c2157" }, "value": 1208329 } ], "hash": "b2b8209b1c0e46cddb6ded0758fc8287a97e6b2bd1f88290c1d374b0bab4a6c8", "txid": "b2b8209b1c0e46cddb6ded0758fc8287a97e6b2bd1f88290c1d374b0bab4a6c8" } 

submitted by Arug_1 to Electrum [link] [comments]

Help with raw BCH transaction - Coinbase Multisig

Been trying to recover an old Coinbase BCH multisig wallet from back in the day and am running into errors after signing the transaction.

I followed this process to get the keys and auth script. http://blog.nerdbank.net/2017/08/how-to-sell-your-coinbase-multi-sig.html?m=1

Now that blockdozer.com is no longer up and running, these kinds of tools don't work like the original Coinb.in method - https://www.reddit.com/btc/comments/6bsc5m/used_the_coinbase_multisig_vault_recovery_tool/
https://bitcoin.stackexchange.com/questions/64493/restore-block-io-multisig-wallet-in-electrum

My last attempt was to use cryptoapis.io on postman to publish the transaction.

When I decode my transaction I get this:
{
"payload": {
"txid": "c210d81d7421df8c29fef9d51ed4762c7c435e37e4e1f0d03da98d7a0ff53707",
"hash": "c210d81d7421df8c29fef9d51ed4762c7c435e37e4e1f0d03da98d7a0ff53707",
"size": 404,
"version": 1,
"locktime": 0,
"vin": [
{
"txid": "3f9c05b991e2da6a45447ad794d4a3ce83ecea4616d6865de51d823e44f6640f",
"sequence": 4294967293,
"vout": 0,
"scriptSig": {
"asm": "0 304402202c751ad9af37e4ac396e4c0517db3155996f4444912f9029c0aca48d7ebcbab102201a0b5abc1dd11377481c04f94bb61607bec3238e8efb85968fbafedf55160d09[ALL] 304502210084c5bab07dd33be1f080ff39994e42139902871d7cedbbd8aa9d1cf4b02d301f02204b275afd22b4ce3b4b60de4204aad2082ecd0bd37e1ac3c2d97dc23fc0d8d681[ALL] 5221038e0a77486457bb154806aa9696f9c09e6160961cf45978e24b3077a457c89b0a410456d2147c0ac68657840bedbc80de83ae2f3f29efb6bec8123ac5c54428e0c88f8c8c2a27fb2c32c9788e70595fc742fba6adc4dab15e8ab4a1a5d89e16025f5b4104c8b2bbb7147082f993f19a8d9641968903c9ad0be35c7e535dc307840a6af470d40eeada1ab8cffc661816423423e1cd1c867704fd436b3ebf25a330ca7eb10d53ae",
"hex": "0047304402202c751ad9af37e4ac396e4c0517db3155996f4444912f9029c0aca48d7ebcbab102201a0b5abc1dd11377481c04f94bb61607bec3238e8efb85968fbafedf55160d090148304502210084c5bab07dd33be1f080ff39994e42139902871d7cedbbd8aa9d1cf4b02d301f02204b275afd22b4ce3b4b60de4204aad2082ecd0bd37e1ac3c2d97dc23fc0d8d681014ca95221038e0a77486457bb154806aa9696f9c09e6160961cf45978e24b3077a457c89b0a410456d2147c0ac68657840bedbc80de83ae2f3f29efb6bec8123ac5c54428e0c88f8c8c2a27fb2c32c9788e70595fc742fba6adc4dab15e8ab4a1a5d89e16025f5b4104c8b2bbb7147082f993f19a8d9641968903c9ad0be35c7e535dc307840a6af470d40eeada1ab8cffc661816423423e1cd1c867704fd436b3ebf25a330ca7eb10d53ae"
}
}
],
"vout": [
{
"value": "0.21192121",
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 e6a79df19f5b69c87231e65005b3b39396368fa0 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914e6a79df19f5b69c87231e65005b3b39396368fa088ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"bitcoincash:qrn20803nadknjrjx8n9qpdnkwfevd505qpqsq8r8w"
]
}
}
]
}
}

But when I try to send the transaction I get this error:

{
"meta": {
"error": {
"code": 4003,
"message": "Cannot send transaction: mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID) (code 16)"
}
}
}

I wasn't able to find much info on this error message. Any help getting this sorted out would be appreciated
submitted by Majestic-Pear-1100 to btc [link] [comments]

With the LN support in master, did CLI or GUI support for CTLV make it in?

CTLV is a type of arbitrary P2SH TXN that allows you to lock a TXN until a certain datetime. It's a bit different from locktime since it is usually used in a N-of-M multisig situation.
I thought that LN required CTLV so was wondering if there is a formal GUI feature for it or CLI to exercise in for on-chain UTXOs now?
submitted by brianddk to Electrum [link] [comments]

[Idea] Bech32 encoding of private keys

Ever since I saw BIP-173 I was excited to see the encoding used anywhere other than addresses. I've done some search but apart from some comments here and there I haven't been able to find any major work done (please let me know if you know of any proposals). Here is my idea of addressing some of the problems with current encoding of private keys:

Using Bech32 encoding instead of Base58

While writing a private key recovery tool I've felt how hard it is to come up with an optimized algorithm to recover a key that is missing a couple of characters (eg. a damaged paper wallet). That is not true with Bech32 being a multiply of base-2 algorithm is inherently faster, and the checksum is not a bottleneck since it is not a hash algorithm. Bech32 also has the benefit of having error detection.

Script (address) type

Currently when a user imports/sweeps a private key in a wallet client, that client either has to explicitly ask user for the script type (like Electrum) which means user is exposed to complications and has to be familiar with script types; or the wallet has to construct all script types and scan the blockchain for all of them (like bitcoin core) which adds more burden on the client. If the encoding included a script type that becomes so much easier.

Locktime!

Another burden on both clients and users (specially full node users) is the time consuming need for a re-scan of the entire blockchain to find the historical transactions that belong to an imported key. A timestamp can make that process a lot shorter. Using locktime (similar to last 4 bytes of any transaction) the key string (aka WIF) could include either a block height or a date-time value of when the key was created.
This idea was added to Bitcoin.Net library as an "experimental" class. Direct link to the code
Here is an example with a random key from Bitcoin.Net KeyHelper class:
Original WIF (Base-58): L28Peud5cQcijrtMthAdUS8FynpM8PKZtnoUZb1VAio9WxKoebHt Key bytes (Base-16): 92734fe879f662ff8ee4eb87dd019425e2ee73ff3edd0c4dc3def2f71e1a6a69 Version byte (ie. the script type): 0x02 or P2WPKH Date UTC: 5/4/2020 7:11:05 AM H.R.P.: bprv New encoding (versioned Bech-32): bprv1zjfe5l6re7e30lrhyawra6qv5yh3wuull8mwscnwrmme0w8s6df5sns90tcqqzyen4e 
Note that key is encoded the same way an address would be encoded (version byte is added separately as a 5-bit value instead of 8-bit).
submitted by Coding_Enthusiast to Bitcoin [link] [comments]

HELP! OverflowError: timestamp out of range for platform time_t

Hi,
I am guessing this means Electrum Wallet is set to a particular time zone, which is not allowing me to send bitcoin. As I tried to send to the exchange and found this error popped up. This is my first time using the wallet and I have no idea how to change the time to sync.
Anyone have an idea what I can do to change it(thats is it is the time issue) so I can send to exchange.
Thanks
Traceback
Traceback (most recent call last): File "/home/dotbin/electrum/electrum/gui/qt/main_window.py", line 1542, in do_pay self.do_pay_invoice(invoice) File "/home/dotbin/electrum/electrum/gui/qt/main_window.py", line 1555, in do_pay_invoice self.pay_onchain_dialog(self.get_coins(), outputs) File "/home/dotbin/electrum/electrum/gui/qt/main_window.py", line 1591, in pay_onchain_dialog external_keypairs=external_keypairs) File "/home/dotbin/electrum/electrum/gui/qt/main_window.py", line 1617, in preview_tx_dialog window=self) File "/home/dotbin/electrum/electrum/gui/qt/transaction_dialog.py", line 690, in __init__ finalized=False, external_keypairs=external_keypairs) File "/home/dotbin/electrum/electrum/gui/qt/transaction_dialog.py", line 126, in __init__ self.add_tx_stats(vbox) File "/home/dotbin/electrum/electrum/gui/qt/transaction_dialog.py", line 634, in add_tx_stats self.locktime_e = LockTimeEdit() File "/home/dotbin/electrum/electrum/gui/qt/locktimeedit.py", line 32, in __init__ self.locktime_date_e = LockTimeDateEdit() File "/home/dotbin/electrum/electrum/gui/qt/locktimeedit.py", line 155, in __init__ self.setMaximumDateTime(datetime.fromtimestamp(self.max_allowed_value)) OverflowError: timestamp out of range for platform time_t
Additional information
submitted by unusual_characters to Electrum [link] [comments]

Signing Issue -- Signature must use SIGHASH_FORKID

Currently integrating my wallet software with Bitcoin Cash, but am having one hell of a time sending funds. I like to think I'm quite well versed with the bitcoin protocol, but this one has me stumped, so any help greatly appreciated.
Keep getting that, "Signature must use SIGHASH_FORKID" error. I know the general format of bitcoin txs, which is basically: Version + Num_Inputs + Inputs + Num_Outputs + Outputs + Locktime. Then I know how to sign via ECDSA, create the DER signatures, etc. That's all no problem.
This 0x40 SIGHASH is causing an issue though. What do I change within the original bitcoin tx to add that 0x40 in there?
I think one thing I have to do, is when getting that double SHA256 hash to sign, instead of adding '00000000' at the end you add '40000000' to get the proper hash to sign. However, what do I change in the DER signature to make this work? At the end of the DER there's a '01' so tried switching that to to 40, and no luck. Tried adding 40 at the end as some docs state, and again no luck.
Any help would be greatly appreciated, as I know this is a 30 second fix that I've already spent 3 days on. Google isn't much help on this one.
submitted by Envrin to Bitcoincash [link] [comments]

[How-To] Crafting an offline TXN with the trezorlib python API

With the rollout of the new 0.12.0 Trezor API, I thought it might be time to update some of my old offline_txn scripts. The following is about 80 lines of python that will craft and sign a VERY simple transaction on Testnet.
The new rollout also comes with some new tools. The build_tx.py that is useful in conjunction with the trezorctl sign_tx command.
Both of the methods below will produce a signed TXN that can then be imported into Electrum using the "Tools -> Load transaction -> From text" command.
Note: u/Crypto-Guide has a good walkthrough for installing trezorlib in Windows if you haven't already done that.

Example of using trezorctl btc sign-tx

This example uses the build_tx.py script to build JSON to feed to the sign-tx command. You will need to download the build_tx.py file from github. It is not automatically installed with the trezor package.
```

python build_tx.py | trezorctl btc sign-tx -

Coin name [Bitcoin]: Testnet Blockbook server [btc1.trezor.io]: tbtc1.trezor.io
Previous output to spend (txid:vout) []: e294c4c172c3d87991...060fad1ed31d12ff00:0 BIP-32 path to derive the key: m/84'/1'/0'/0/0 Input amount: 129999866 Sequence Number to use (RBF opt-in enabled by default) [4294967293]: Input type (address, segwit, p2shsegwit) [segwit]:
Previous output to spend (txid:vout) []:
Output address (for non-change output) []: 2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3 Amount to spend (satoshis): 129999706
Output address (for non-change output) []: BIP-32 path (for change output) []: Transaction version [2]: Transaction locktime [0]: Please confirm action on your Trezor device.
Signed Transaction: 0200000000010100ff121dd31ead0f06...f279b642d85c48798685f86200000000 ```

Example of using crafting a TXN using trezorlib directly

If your good with python, or want to see how everything works under the hood, here's 80 lines of python to generate a similar signed transaction.
```python

!/usbin/env python3

[repo] https://github.com/brianddk/reddit ... python/offline_txn.py

[req] pip3 install trezor

from trezorlib import btc, messages as proto, tools, ui from trezorlib import MINIMUM_FIRMWARE_VERSION as min_version from trezorlib.client import TrezorClient from trezorlib.transport import get_transport from trezorlib.btc import from_json from json import loads from decimal import Decimal from sys import exit

Tested with SLIP-0014 allallall seed (slip-0014.md)

User Provided Fields; These are pulled from test scripts

CHANGE THESE!!!

coin = "Testnet"

Get legacy UTXO prev_txn hex from blockbook server. For example:

https://tbtc1.trezor.io/api/tx-specific/ \

e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00

in1_prev_txn_s = '{"txid":' \ '"e294c4c172c3d87991b0369e45d6af8584be92914d01e3060fad1ed31d12ff00"}'
in1_prev_index = 0 in1_addr_path = "m/84'/1'/0'/0/0" # allallall seed in1_amount = 129999867 out1_address = "2MsiAgG5LVDmnmJUPnYaCeQnARWGbGSVnr3" out1_amount = in1_amount - 192

Defaults

tx_version = 2 tx_locktime = 0 sequence = 4294967293

Code

in1_prev_txn_j = loads(in1_prev_txn_s, parse_float=Decimal) in1_prev_hash = in1_prev_txn_j['txid'] in1_prev_hash_b = bytes.fromhex(in1_prev_hash) device = get_transport() client = TrezorClient(transport=device, ui=ui.ClickUI())
fw_version = (client.features.major_version, client.features.minor_version, client.features.patch_version) if fw_version < min_version[client.features.model]: print("Please flash to the latest FW") exit(1)
signtx = proto.SignTx( version = tx_version, lock_time = tx_locktime )
ins = [proto.TxInputType( address_n=tools.parse_path(in1_addr_path), prev_hash=in1_prev_hash_b, prev_index=in1_prev_index, amount=in1_amount, script_type=proto.InputScriptType.SPENDWITNESS, sequence=sequence )] outs = [proto.TxOutputType( address=out1_address, amount=out1_amount, script_type=proto.OutputScriptType.PAYTOADDRESS )]
txes = None for i in ins: if i.script_type == proto.InputScriptType.SPENDADDRESS: tx = from_json(in1_prev_txn_j) txes = {in1_prev_hash_b: tx} break
_, serialized_tx = btc.sign_tx(client, coin, ins, outs, details=signtx, prev_txes=txes) client.close() print(f'{{"hex": "{serialized_tx.hex()}"}}') ```
From here, you simple take the resultant TXN hex and import it into Electrum using the "Tools -> Load transaction -> From text" clickpath
submitted by brianddk to Bitcoin [link] [comments]

Technical: Upcoming Improvements to Lightning Network

Price? Who gives a shit about price when Lightning Network development is a lot more interesting?????
One thing about LN is that because there's no need for consensus before implementing things, figuring out the status of things is quite a bit more difficult than on Bitcoin. In one hand it lets larger groups of people work on improving LN faster without having to coordinate so much. On the other hand it leads to some fragmentation of the LN space, with compatibility problems occasionally coming up.
The below is just a smattering sample of LN stuff I personally find interesting. There's a bunch of other stuff, like splice and dual-funding, that I won't cover --- post is long enough as-is, and besides, some of the below aren't as well-known.
Anyway.....

"eltoo" Decker-Russell-Osuntokun

Yeah the exciting new Lightning Network channel update protocol!

Advantages

Myths

Disadvantages

Multipart payments / AMP

Splitting up large payments into smaller parts!

Details

Advantages

Disadvantages

Payment points / scalars

Using the magic of elliptic curve homomorphism for fun and Lightning Network profits!
Basically, currently on Lightning an invoice has a payment hash, and the receiver reveals a payment preimage which, when inputted to SHA256, returns the given payment hash.
Instead of using payment hashes and preimages, just replace them with payment points and scalars. An invoice will now contain a payment point, and the receiver reveals a payment scalar (private key) which, when multiplied with the standard generator point G on secp256k1, returns the given payment point.
This is basically Scriptless Script usage on Lightning, instead of HTLCs we have Scriptless Script Pointlocked Timelocked Contracts (PTLCs).

Advantages

Disadvantages

Pay-for-data

Ensuring that payers cannot access data or other digital goods without proof of having paid the provider.
In a nutshell: the payment preimage used as a proof-of-payment is the decryption key of the data. The provider gives the encrypted data, and issues an invoice. The buyer of the data then has to pay over Lightning in order to learn the decryption key, with the decryption key being the payment preimage.

Advantages

Disadvantages

Stuckless payments

No more payments getting stuck somewhere in the Lightning network without knowing whether the payee will ever get paid!
(that's actually a bit overmuch claim, payments still can get stuck, but what "stuckless" really enables is that we can now safely run another parallel payment attempt until any one of the payment attempts get through).
Basically, by using the ability to add points together, the payer can enforce that the payee can only claim the funds if it knows two pieces of information:
  1. The payment scalar corresponding to the payment point in the invoice signed by the payee.
  2. An "acknowledgment" scalar provided by the payer to the payee via another communication path.
This allows the payer to make multiple payment attempts in parallel, unlike the current situation where we must wait for an attempt to fail before trying another route. The payer only needs to ensure it generates different acknowledgment scalars for each payment attempt.
Then, if at least one of the payment attempts reaches the payee, the payee can then acquire the acknowledgment scalar from the payer. Then the payee can acquire the payment. If the payee attempts to acquire multiple acknowledgment scalars for the same payment, the payer just gives out one and then tells the payee "LOL don't try to scam me", so the payee can only acquire a single acknowledgment scalar, meaning it can only claim a payment once; it can't claim multiple parallel payments.

Advantages

Disadvantages

Non-custodial escrow over Lightning

The "acknowledgment" scalar used in stuckless can be reused here.
The acknowledgment scalar is derived as an ECDH shared secret between the payer and the escrow service. On arrival of payment to the payee, the payee queries the escrow to determine if the acknowledgment point is from a scalar that the escrow can derive using ECDH with the payer, plus a hash of the contract terms of the trade (for example, to transfer some goods in exchange for Lightning payment). Once the payee gets confirmation from the escrow that the acknowledgment scalar is known by the escrow, the payee performs the trade, then asks the payer to provide the acknowledgment scalar once the trade completes.
If the payer refuses to give the acknowledgment scalar even though the payee has given over the goods to be traded, then the payee contacts the escrow again, reveals the contract terms text, and requests to be paid. If the escrow finds in favor of the payee (i.e. it determines the goods have arrived at the payer as per the contract text) then it gives the acknowledgment scalar to the payee.

Advantages

Disadvantages

Payment decorrelation

Because elliptic curve points can be added (unlike hashes), for every forwarding node, we an add a "blinding" point / scalar. This prevents multiple forwarding nodes from discovering that they have been on the same payment route. This is unlike the current payment hash + preimage, where the same hash is used along the route.
In fact, the acknowledgment scalar we use in stuckless and escrow can simply be the sum of each blinding scalar used at each forwarding node.

Advantages

Disadvantages

submitted by almkglor to Bitcoin [link] [comments]

Short ELI5 text for gift of bitcoin

Greetings:

I am a true believer in the blockchain, and believe it may become something much greater 20+ years down the road. My best friend has a ton of offspring, and I have none (and plan to have none). I intend to give each of their children $100 worth of bitcoin in today's value in the form of a metal offline wallet (I have access to a nifty metal engraver).

They will be given the public key only, and a note. The note is what I need help with. My intention is to describe to them that they will receive the private key on their 18th birthday, and until then they are free to check their balance or add to it. I intend to include extra incentive to HODL, in that if after their 18th birthday and receipt of the private key they do not transfer any bitcoin from the wallet, from time to time on Birthdays and such I might deposit more bitcoin. However the moment any transfer out of the wallet occurs, all future new deposits from me will stop.

The goal here is to use bitcoin to get them interested in investing in their future (we also talk a lot about traditional FIAT investing and retirement planning).

The main part I need help with is how to keep a description of bitcoin/blockchain technology and how it relates to traditional value holders, and the importance of long-term gain possibilities, while also explaining the volatility and potential for it to drop to zero some day (e.g., the risk). I can explain all of this to someone but it takes me several paragraphs, I'm long-winded. I'm trying to get this boiled down to 3-4 sentences so it fits in a greeting card, and also simple enough for a 10-12 year old to understand it.

Help please. :)
submitted by gh2222 to Bitcoin [link] [comments]

The Bitcoin Foundation - YouTube Lascia i tuoi bitcoin prima di morire cripto eredità/testamento/successione Don't Trade Your Bitcoin!  Escape from Tarkov Economics ... What Are Hashed Lock Contracts? Applications In Bitcoin Payment Channels BEGINNER: Bitcoin vs Lightning payments Hashed Time Locked contracts Explained

From Bitcoin Wiki. Jump to: navigation, search. A Hash Time Locked Contract or HTLC is a class of payments that use hashlocks and timelocks to require that the receiver of a payment either acknowledge receiving the payment prior to a deadline by generating cryptographic proof of payment or forfeit the ability to claim the payment, returning it to the payer. The cryptographic proof of payment ... In Bitcoin 0.1.6, the interpretation of nLockTime was adjusted to also allow time-based locking. Then, starting from block 31001 ... Relative locktime. In mid-2016, the BIP68/112/113 soft fork gave consensus-enforced meaning to some values in the nSequence field that is a part of every transaction input, creating a "relative locktime" [citation needed]. This allowed an input to specify the ... Relative locktime . In mid-2016, the BIP68/112/113 soft fork gave consensus-enforced meaning to some values in the nSequence field that is a part of every transaction input, creating a "relative locktime". This allowed an input to specify the earliest time it can be added to a block based on how long ago the output being spent by that input was ... Locktime Decimal Descrpition; 0xede80600: 452845: This transaction could only be relayed on the network after the blockchain reached a height of 452,845.(0x06241559: 1494557702: This is Fri, 12 May 2017 02:55:02 in Unix Time. The transaction could only be relayed on the network after the median time of the last 11 blocks (according to the time field in their block headers) is greater than this. Bitcoin transactions are a composite data structure which includes inputs and outputs. The entire script follows a very basic, but effective, script that processes one operation at a time. All adding a locktime does is specify at what point in the future the transaction can be confirmed. Locktime appears at the end of the sequence. It is set using

[index] [47378] [9467] [9002] [48659] [22652] [8464] [16038] [2835] [29953] [11656]

The Bitcoin Foundation - YouTube

Get a 30-day free trial of Dashlane here: https://www.dashlane.com/infographics Use the code "infographics" for 10% off of Dashlane Premium! It’s one of the ... In this presentation we talk about Hashed Contracts which have an application in payment channels and atomic swaps. We go through an example in which we talk about how do these work in a Bitcoin ... 'Fake Bitcoin' - How this Woman Scammed the World, then Vanished - Duration: 17:50. ColdFusion Recommended for you. 17:50. 1. mappa del tesoro; il modo più semplice per passare i tuoi bitcoin in eredità è quello di trascrivere in modo dettagliato tutte le informazioni necessarie al tuo beneficiario. Non è ... PLEASE HELP ME WIN THE RTX STREAM ON CONTEST BY FOLLOWING ME ON TWITCH!! http://www.twitch.tv/veritas https://www.nvidia.com/en-us/geforce/20-series/rtx-for-...

#