Skip to content

Instantly share code, notes, and snippets.

@davecgh
davecgh / decred_example_txscript_step.go
Last active November 5, 2023 18:12
Example of stepping through a Decred script using the txscript API.
package main
import (
"encoding/hex"
"fmt"
"os"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/txscript/v4"
"github.com/decred/dcrd/wire"
@davecgh
davecgh / pubkey_to_addr.go
Last active April 19, 2023 01:22
Example of converting a raw public key to a btcutil.Address.
package main
import (
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
)
func main() {
@davecgh
davecgh / p2sh_multisig_types.go
Last active December 24, 2020 10:32
P2SH Multisig Types
package main
import (
"encoding/hex"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
. "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
)
@davecgh
davecgh / simnetblksubmit.go
Created February 18, 2015 21:05
Example of connecting to a simnet btcd instance, manually generating blocks, and submitting them.
package main
import (
"encoding/binary"
"errors"
"io/ioutil"
"log"
"math"
"math/big"
"path/filepath"
@davecgh
davecgh / btcdwstest.html
Last active July 29, 2020 10:16
btcd Browser Websocket Connection Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = 'wss://127.0.0.1:8334/ws';
var rpcUser = "rpcuser";
var rpcPass = "rpcpass";
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davecgh
davecgh / example_txscript_step.go
Last active March 8, 2019 07:01
Example of stepping through a script using the txscript API.
package main
import (
"encoding/hex"
"fmt"
"os"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
@davecgh
davecgh / dcr_offline_multisig_p2sh_example.go
Created January 15, 2019 11:49
Sample code to create and sign an offline p2sh 2-of-3 multisig transaction given WIF-encoded private keys
package main
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/decred/dcrd/chaincfg"
"github.com/decred/dcrd/dcrec/secp256k1"
"github.com/decred/dcrd/dcrutil"
@davecgh
davecgh / masternode.conf
Created February 25, 2016 04:03
Example btcd config files for 8 node simnet network
rpcuser=youruser
rpcpass=SomeDecentp4ssw0rd
simnet=1
logdir=~/btcdsimnetnodes/master/log
datadir=~/btcdsimnetnodes/master/data
listen=127.0.0.1:18555
connect=127.0.0.1:18501
connect=127.0.0.1:18502
connect=127.0.0.1:18503
connect=127.0.0.1:18504