Skip to content

Commit 62f77c0

Browse files
authored
Merge pull request ProgrammingBlockchain#142 from yahiheb/errors-updates
Fix some errors and update some code
2 parents a4d1e99 + 81918a8 commit 62f77c0

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

bitcoin_transfer/bitcoin_address.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Console.WriteLine(publicKey.GetAddress(ScriptPubKeyType.Legacy, Network.TestNet)
4141
```cs
4242
var publicKeyHash = publicKey.Hash;
4343
Console.WriteLine(publicKeyHash); // f6889b21b5540353a29ed18c45ea0031280c42cf
44-
var mainNetAddress = publicKeyHash.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
45-
var testNetAddress = publicKeyHash.GetAddress(ScriptPubKeyType.Legacy, Network.TestNet);
44+
var mainNetAddress = publicKeyHash.GetAddress(Network.Main);
45+
var testNetAddress = publicKeyHash.GetAddress(Network.TestNet);
4646
```
4747

4848
> **Fact:** A public key hash is generated by using a SHA256 hash on the public key, then a RIPEMD160 hash on the result, using Big Endian notation. The function could look like this: RIPEMD160(SHA256(pubkey))

bitcoin_transfer/payment_script.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ We are able to generate the ScriptPubKey from the Bitcoin Address. This is a ste
1414
```cs
1515
var publicKeyHash = new KeyId("14836dbe7f38c5ac3d49e8d790af808a4ee9edcf");
1616

17-
var testNetAddress = publicKeyHash.GetAddress(ScriptPubKeyType.Legacy, Network.TestNet);
18-
var mainNetAddress = publicKeyHash.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
17+
var testNetAddress = publicKeyHash.GetAddress(Network.TestNet);
18+
var mainNetAddress = publicKeyHash.GetAddress(Network.Main);
1919

2020
Console.WriteLine(mainNetAddress.ScriptPubKey); // OP_DUP OP_HASH160 14836dbe7f38c5ac3d49e8d790af808a4ee9edcf OP_EQUALVERIFY OP_CHECKSIG
2121
Console.WriteLine(testNetAddress.ScriptPubKey); // OP_DUP OP_HASH160 14836dbe7f38c5ac3d49e8d790af808a4ee9edcf OP_EQUALVERIFY OP_CHECKSIG

bitcoin_transfer/private_key.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Private keys are often represented in Base58Check called a **Bitcoin Secret** (a
66

77
```cs
88
Key privateKey = new Key(); // generate a random private key
9-
BitcoinSecret mainNetPrivateKey = privateKey.GetBitcoinSecret(ScriptPubKeyType.Legacy, Network.Main); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the mainnet
10-
BitcoinSecret testNetPrivateKey = privateKey.GetBitcoinSecret(ScriptPubKeyType.Legacy, Network.TestNet); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the testnet
9+
BitcoinSecret mainNetPrivateKey = privateKey.GetBitcoinSecret(Network.Main); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the mainnet
10+
BitcoinSecret testNetPrivateKey = privateKey.GetBitcoinSecret(Network.TestNet); // generate our Bitcoin secret(also known as Wallet Import Format or simply WIF) from our private key for the testnet
1111
Console.WriteLine(mainNetPrivateKey); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvn
1212
Console.WriteLine(testNetPrivateKey); // cVY5auviDh8LmYUW8AfafseD6p6uFoZrP7GjS3rzAerpRKE9Wmuz
1313

key_generation/bip_32.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ masterKey = new ExtKey();
7676
masterPubKey = masterKey.Neuter();
7777

7878
//The payment server generate pubkey1
79-
ExtPubKey pubkey1 = masterPubKey.Derive((uint)1);
79+
ExtPubKey pubkey1 = masterPubKey.Derive(1);
8080

8181
//You get the private key of pubkey1
82-
ExtKey key1 = masterKey.Derive((uint)1);
82+
ExtKey key1 = masterKey.Derive(1);
8383

8484
//Check it is legit
8585
Console.WriteLine("Generated address : " + pubkey1.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main));

other_types_of_asset/issuing_an_asset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var tx = builder
5454
.AddCoins(issuance)
5555
.IssueAsset(nico, new AssetMoney(issuance.AssetId, quantity: 10))
5656
.SendFees(Money.Coins(0.0001m))
57-
.SetChange(bookKey.GetAddress())
57+
.SetChange(bookKey.GetAddress(ScriptPubKeyType.Legacy))
5858
.BuildTransaction(true);
5959

6060
Console.WriteLine(tx);

other_types_of_ownership/arbitrary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ So first, let’s build the **RedeemScript**,
1515
```cs
1616
BitcoinAddress address = BitcoinAddress.Create("1KF8kUVHK42XzgcmJF4Lxz4wcL5WDL97PB", Network.Main);
1717
var birth = Encoding.UTF8.GetBytes("18/07/1988");
18-
var birthHash = Hashes.Hash256(birth);
18+
var birthHash = Hashes.DoubleSHA256(birth);
1919
Script redeemScript = new Script(
2020
"OP_IF "
2121
+ "OP_HASH256 " + Op.GetPushOp(birthHash.ToBytes()) + " OP_EQUAL " +

0 commit comments

Comments
 (0)