id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,300 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/ExchangeRate.java | ExchangeRate.fiatToCoin | public Coin fiatToCoin(Fiat convertFiat) {
checkArgument(convertFiat.currencyCode.equals(fiat.currencyCode), "Currency mismatch: %s vs %s",
convertFiat.currencyCode, fiat.currencyCode);
// Use BigInteger because it's much easier to maintain full precision without overflowing.
fin... | java | public Coin fiatToCoin(Fiat convertFiat) {
checkArgument(convertFiat.currencyCode.equals(fiat.currencyCode), "Currency mismatch: %s vs %s",
convertFiat.currencyCode, fiat.currencyCode);
// Use BigInteger because it's much easier to maintain full precision without overflowing.
fin... | [
"public",
"Coin",
"fiatToCoin",
"(",
"Fiat",
"convertFiat",
")",
"{",
"checkArgument",
"(",
"convertFiat",
".",
"currencyCode",
".",
"equals",
"(",
"fiat",
".",
"currencyCode",
")",
",",
"\"Currency mismatch: %s vs %s\"",
",",
"convertFiat",
".",
"currencyCode",
"... | Convert a fiat amount to a coin amount using this exchange rate.
@throws ArithmeticException if the converted coin amount is too high or too low. | [
"Convert",
"a",
"fiat",
"amount",
"to",
"a",
"coin",
"amount",
"using",
"this",
"exchange",
"rate",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java#L68-L82 |
23,301 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java | BIP38PrivateKey.fromBase58 | public static BIP38PrivateKey fromBase58(NetworkParameters params, String base58) throws AddressFormatException {
byte[] versionAndDataBytes = Base58.decodeChecked(base58);
int version = versionAndDataBytes[0] & 0xFF;
byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.... | java | public static BIP38PrivateKey fromBase58(NetworkParameters params, String base58) throws AddressFormatException {
byte[] versionAndDataBytes = Base58.decodeChecked(base58);
int version = versionAndDataBytes[0] & 0xFF;
byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.... | [
"public",
"static",
"BIP38PrivateKey",
"fromBase58",
"(",
"NetworkParameters",
"params",
",",
"String",
"base58",
")",
"throws",
"AddressFormatException",
"{",
"byte",
"[",
"]",
"versionAndDataBytes",
"=",
"Base58",
".",
"decodeChecked",
"(",
"base58",
")",
";",
"... | Construct a password-protected private key from its Base58 representation.
@param params
The network parameters of the chain that the key is for.
@param base58
The textual form of the password-protected private key.
@throws AddressFormatException
if the given base58 doesn't parse or the checksum is invalid | [
"Construct",
"a",
"password",
"-",
"protected",
"private",
"key",
"from",
"its",
"Base58",
"representation",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java#L57-L96 |
23,302 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java | MarriedKeyChain.freshOutputScript | @Override
public Script freshOutputScript(KeyPurpose purpose) {
DeterministicKey followedKey = getKey(purpose);
ImmutableList.Builder<ECKey> keys = ImmutableList.<ECKey>builder().add(followedKey);
for (DeterministicKeyChain keyChain : followingKeyChains) {
DeterministicKey follow... | java | @Override
public Script freshOutputScript(KeyPurpose purpose) {
DeterministicKey followedKey = getKey(purpose);
ImmutableList.Builder<ECKey> keys = ImmutableList.<ECKey>builder().add(followedKey);
for (DeterministicKeyChain keyChain : followingKeyChains) {
DeterministicKey follow... | [
"@",
"Override",
"public",
"Script",
"freshOutputScript",
"(",
"KeyPurpose",
"purpose",
")",
"{",
"DeterministicKey",
"followedKey",
"=",
"getKey",
"(",
"purpose",
")",
";",
"ImmutableList",
".",
"Builder",
"<",
"ECKey",
">",
"keys",
"=",
"ImmutableList",
".",
... | Create a new married key and return the matching output script | [
"Create",
"a",
"new",
"married",
"key",
"and",
"return",
"the",
"matching",
"output",
"script"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java#L151-L163 |
23,303 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java | MarriedKeyChain.getRedeemData | @Override
public RedeemData getRedeemData(DeterministicKey followedKey) {
List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey);
Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys);
return RedeemData.of(marriedKeys, redeemScript);
} | java | @Override
public RedeemData getRedeemData(DeterministicKey followedKey) {
List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey);
Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys);
return RedeemData.of(marriedKeys, redeemScript);
} | [
"@",
"Override",
"public",
"RedeemData",
"getRedeemData",
"(",
"DeterministicKey",
"followedKey",
")",
"{",
"List",
"<",
"ECKey",
">",
"marriedKeys",
"=",
"getMarriedKeysWithFollowed",
"(",
"followedKey",
")",
";",
"Script",
"redeemScript",
"=",
"ScriptBuilder",
"."... | Get the redeem data for a key in this married chain | [
"Get",
"the",
"redeem",
"data",
"for",
"a",
"key",
"in",
"this",
"married",
"chain"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java#L176-L181 |
23,304 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java | WalletProtobufSerializer.walletToProto | public Protos.Wallet walletToProto(Wallet wallet) {
Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder();
walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId());
if (wallet.getDescription() != null) {
walletBuilder.setDescription(wallet.getDescription()... | java | public Protos.Wallet walletToProto(Wallet wallet) {
Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder();
walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId());
if (wallet.getDescription() != null) {
walletBuilder.setDescription(wallet.getDescription()... | [
"public",
"Protos",
".",
"Wallet",
"walletToProto",
"(",
"Wallet",
"wallet",
")",
"{",
"Protos",
".",
"Wallet",
".",
"Builder",
"walletBuilder",
"=",
"Protos",
".",
"Wallet",
".",
"newBuilder",
"(",
")",
";",
"walletBuilder",
".",
"setNetworkIdentifier",
"(",
... | Converts the given wallet to the object representation of the protocol buffers. This can be modified, or
additional data fields set, before serialization takes place. | [
"Converts",
"the",
"given",
"wallet",
"to",
"the",
"object",
"representation",
"of",
"the",
"protocol",
"buffers",
".",
"This",
"can",
"be",
"modified",
"or",
"additional",
"data",
"fields",
"set",
"before",
"serialization",
"takes",
"place",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java#L175-L241 |
23,305 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java | WalletProtobufSerializer.isWallet | public static boolean isWallet(InputStream is) {
try {
final CodedInputStream cis = CodedInputStream.newInstance(is);
final int tag = cis.readTag();
final int field = WireFormat.getTagFieldNumber(tag);
if (field != 1) // network_identifier
return f... | java | public static boolean isWallet(InputStream is) {
try {
final CodedInputStream cis = CodedInputStream.newInstance(is);
final int tag = cis.readTag();
final int field = WireFormat.getTagFieldNumber(tag);
if (field != 1) // network_identifier
return f... | [
"public",
"static",
"boolean",
"isWallet",
"(",
"InputStream",
"is",
")",
"{",
"try",
"{",
"final",
"CodedInputStream",
"cis",
"=",
"CodedInputStream",
".",
"newInstance",
"(",
"is",
")",
";",
"final",
"int",
"tag",
"=",
"cis",
".",
"readTag",
"(",
")",
... | Cheap test to see if input stream is a wallet. This checks for a magic value at the beginning of the stream.
@param is
input stream to test
@return true if input stream is a wallet | [
"Cheap",
"test",
"to",
"see",
"if",
"input",
"stream",
"is",
"a",
"wallet",
".",
"This",
"checks",
"for",
"a",
"magic",
"value",
"at",
"the",
"beginning",
"of",
"the",
"stream",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java#L835-L847 |
23,306 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java | DatabaseFullPrunedBlockStore.getCompatibilitySQL | protected List<String> getCompatibilitySQL() {
List<String> sqlStatements = new ArrayList<>();
sqlStatements.add(SELECT_COMPATIBILITY_COINBASE_SQL);
return sqlStatements;
} | java | protected List<String> getCompatibilitySQL() {
List<String> sqlStatements = new ArrayList<>();
sqlStatements.add(SELECT_COMPATIBILITY_COINBASE_SQL);
return sqlStatements;
} | [
"protected",
"List",
"<",
"String",
">",
"getCompatibilitySQL",
"(",
")",
"{",
"List",
"<",
"String",
">",
"sqlStatements",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"sqlStatements",
".",
"add",
"(",
"SELECT_COMPATIBILITY_COINBASE_SQL",
")",
";",
"return",... | Get the SQL statements to check if the database is compatible.
@return The SQL prepared statements. | [
"Get",
"the",
"SQL",
"statements",
"to",
"check",
"if",
"the",
"database",
"is",
"compatible",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java#L240-L244 |
23,307 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java | DatabaseFullPrunedBlockStore.initFromDatabase | private void initFromDatabase() throws SQLException, BlockStoreException {
PreparedStatement ps = conn.get().prepareStatement(getSelectSettingsSQL());
ResultSet rs;
ps.setString(1, CHAIN_HEAD_SETTING);
rs = ps.executeQuery();
if (!rs.next()) {
throw new BlockStoreExce... | java | private void initFromDatabase() throws SQLException, BlockStoreException {
PreparedStatement ps = conn.get().prepareStatement(getSelectSettingsSQL());
ResultSet rs;
ps.setString(1, CHAIN_HEAD_SETTING);
rs = ps.executeQuery();
if (!rs.next()) {
throw new BlockStoreExce... | [
"private",
"void",
"initFromDatabase",
"(",
")",
"throws",
"SQLException",
",",
"BlockStoreException",
"{",
"PreparedStatement",
"ps",
"=",
"conn",
".",
"get",
"(",
")",
".",
"prepareStatement",
"(",
"getSelectSettingsSQL",
"(",
")",
")",
";",
"ResultSet",
"rs",... | Initialise the store state from the database.
@throws java.sql.SQLException If there is a database error.
@throws BlockStoreException If there is a block store error. | [
"Initialise",
"the",
"store",
"state",
"from",
"the",
"database",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java#L575-L603 |
23,308 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java | DatabaseFullPrunedBlockStore.resetStore | public void resetStore() throws BlockStoreException {
maybeConnect();
try {
deleteStore();
createTables();
initFromDatabase();
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
} | java | public void resetStore() throws BlockStoreException {
maybeConnect();
try {
deleteStore();
createTables();
initFromDatabase();
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"void",
"resetStore",
"(",
")",
"throws",
"BlockStoreException",
"{",
"maybeConnect",
"(",
")",
";",
"try",
"{",
"deleteStore",
"(",
")",
";",
"createTables",
"(",
")",
";",
"initFromDatabase",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e... | Resets the store by deleting the contents of the tables and reinitialising them.
@throws BlockStoreException If the tables couldn't be cleared and initialised. | [
"Resets",
"the",
"store",
"by",
"deleting",
"the",
"contents",
"of",
"the",
"tables",
"and",
"reinitialising",
"them",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java#L1078-L1087 |
23,309 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java | DatabaseFullPrunedBlockStore.deleteStore | public void deleteStore() throws BlockStoreException {
maybeConnect();
try {
Statement s = conn.get().createStatement();
for(String sql : getDropTablesSQL()) {
s.execute(sql);
}
s.close();
} catch (SQLException ex) {
thr... | java | public void deleteStore() throws BlockStoreException {
maybeConnect();
try {
Statement s = conn.get().createStatement();
for(String sql : getDropTablesSQL()) {
s.execute(sql);
}
s.close();
} catch (SQLException ex) {
thr... | [
"public",
"void",
"deleteStore",
"(",
")",
"throws",
"BlockStoreException",
"{",
"maybeConnect",
"(",
")",
";",
"try",
"{",
"Statement",
"s",
"=",
"conn",
".",
"get",
"(",
")",
".",
"createStatement",
"(",
")",
";",
"for",
"(",
"String",
"sql",
":",
"g... | Deletes the store by deleting the tables within the database.
@throws BlockStoreException If tables couldn't be deleted. | [
"Deletes",
"the",
"store",
"by",
"deleting",
"the",
"tables",
"within",
"the",
"database",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java#L1093-L1104 |
23,310 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java | DatabaseFullPrunedBlockStore.calculateBalanceForAddress | public BigInteger calculateBalanceForAddress(Address address) throws BlockStoreException {
maybeConnect();
PreparedStatement s = null;
try {
s = conn.get().prepareStatement(getBalanceSelectSQL());
s.setString(1, address.toString());
ResultSet rs = s.executeQue... | java | public BigInteger calculateBalanceForAddress(Address address) throws BlockStoreException {
maybeConnect();
PreparedStatement s = null;
try {
s = conn.get().prepareStatement(getBalanceSelectSQL());
s.setString(1, address.toString());
ResultSet rs = s.executeQue... | [
"public",
"BigInteger",
"calculateBalanceForAddress",
"(",
"Address",
"address",
")",
"throws",
"BlockStoreException",
"{",
"maybeConnect",
"(",
")",
";",
"PreparedStatement",
"s",
"=",
"null",
";",
"try",
"{",
"s",
"=",
"conn",
".",
"get",
"(",
")",
".",
"p... | Calculate the balance for a coinbase, to-address, or p2sh address.
<p>The balance {@link DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
the balance (summed) as an number, then use calculateClientSide=false</p>
<p>The balance {@link DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
the all the o... | [
"Calculate",
"the",
"balance",
"for",
"a",
"coinbase",
"to",
"-",
"address",
"or",
"p2sh",
"address",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java#L1120-L1143 |
23,311 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/DeterministicHierarchy.java | DeterministicHierarchy.get | public DeterministicKey get(List<ChildNumber> path, boolean relativePath, boolean create) {
ImmutableList<ChildNumber> absolutePath = relativePath
? ImmutableList.<ChildNumber>builder().addAll(rootPath).addAll(path).build()
: ImmutableList.copyOf(path);
if (!keys.contains... | java | public DeterministicKey get(List<ChildNumber> path, boolean relativePath, boolean create) {
ImmutableList<ChildNumber> absolutePath = relativePath
? ImmutableList.<ChildNumber>builder().addAll(rootPath).addAll(path).build()
: ImmutableList.copyOf(path);
if (!keys.contains... | [
"public",
"DeterministicKey",
"get",
"(",
"List",
"<",
"ChildNumber",
">",
"path",
",",
"boolean",
"relativePath",
",",
"boolean",
"create",
")",
"{",
"ImmutableList",
"<",
"ChildNumber",
">",
"absolutePath",
"=",
"relativePath",
"?",
"ImmutableList",
".",
"<",
... | Returns a key for the given path, optionally creating it.
@param path the path to the key
@param relativePath whether the path is relative to the root path
@param create whether the key corresponding to path should be created (with any necessary ancestors) if it doesn't exist already
@return next newly created key usi... | [
"Returns",
"a",
"key",
"for",
"the",
"given",
"path",
"optionally",
"creating",
"it",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/DeterministicHierarchy.java#L83-L96 |
23,312 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Base58.java | Base58.encodeChecked | public static String encodeChecked(int version, byte[] payload) {
if (version < 0 || version > 255)
throw new IllegalArgumentException("Version not in range.");
// A stringified buffer is:
// 1 byte version + data bytes + 4 bytes check code (a truncated hash)
byte[] addressB... | java | public static String encodeChecked(int version, byte[] payload) {
if (version < 0 || version > 255)
throw new IllegalArgumentException("Version not in range.");
// A stringified buffer is:
// 1 byte version + data bytes + 4 bytes check code (a truncated hash)
byte[] addressB... | [
"public",
"static",
"String",
"encodeChecked",
"(",
"int",
"version",
",",
"byte",
"[",
"]",
"payload",
")",
"{",
"if",
"(",
"version",
"<",
"0",
"||",
"version",
">",
"255",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Version not in range.\"",
... | Encodes the given version and bytes as a base58 string. A checksum is appended.
@param version the version to encode
@param payload the bytes to encode, e.g. pubkey hash
@return the base58-encoded string | [
"Encodes",
"the",
"given",
"version",
"and",
"bytes",
"as",
"a",
"base58",
"string",
".",
"A",
"checksum",
"is",
"appended",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Base58.java#L101-L113 |
23,313 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Base58.java | Base58.decode | public static byte[] decode(String input) throws AddressFormatException {
if (input.length() == 0) {
return new byte[0];
}
// Convert the base58-encoded ASCII chars to a base58 byte sequence (base58 digits).
byte[] input58 = new byte[input.length()];
for (int i = 0; i... | java | public static byte[] decode(String input) throws AddressFormatException {
if (input.length() == 0) {
return new byte[0];
}
// Convert the base58-encoded ASCII chars to a base58 byte sequence (base58 digits).
byte[] input58 = new byte[input.length()];
for (int i = 0; i... | [
"public",
"static",
"byte",
"[",
"]",
"decode",
"(",
"String",
"input",
")",
"throws",
"AddressFormatException",
"{",
"if",
"(",
"input",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"new",
"byte",
"[",
"0",
"]",
";",
"}",
"// Convert the ba... | Decodes the given base58 string into the original data bytes.
@param input the base58-encoded string to decode
@return the decoded data bytes
@throws AddressFormatException if the given string is not a valid base58 string | [
"Decodes",
"the",
"given",
"base58",
"string",
"into",
"the",
"original",
"data",
"bytes",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Base58.java#L122-L156 |
23,314 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Base58.java | Base58.decodeChecked | public static byte[] decodeChecked(String input) throws AddressFormatException {
byte[] decoded = decode(input);
if (decoded.length < 4)
throw new AddressFormatException.InvalidDataLength("Input too short: " + decoded.length);
byte[] data = Arrays.copyOfRange(decoded, 0, decoded.len... | java | public static byte[] decodeChecked(String input) throws AddressFormatException {
byte[] decoded = decode(input);
if (decoded.length < 4)
throw new AddressFormatException.InvalidDataLength("Input too short: " + decoded.length);
byte[] data = Arrays.copyOfRange(decoded, 0, decoded.len... | [
"public",
"static",
"byte",
"[",
"]",
"decodeChecked",
"(",
"String",
"input",
")",
"throws",
"AddressFormatException",
"{",
"byte",
"[",
"]",
"decoded",
"=",
"decode",
"(",
"input",
")",
";",
"if",
"(",
"decoded",
".",
"length",
"<",
"4",
")",
"throw",
... | Decodes the given base58 string into the original data bytes, using the checksum in the
last 4 bytes of the decoded data to verify that the rest are correct. The checksum is
removed from the returned data.
@param input the base58-encoded string to decode (which should include the checksum)
@throws AddressFormatExcepti... | [
"Decodes",
"the",
"given",
"base58",
"string",
"into",
"the",
"original",
"data",
"bytes",
"using",
"the",
"checksum",
"in",
"the",
"last",
"4",
"bytes",
"of",
"the",
"decoded",
"data",
"to",
"verify",
"that",
"the",
"rest",
"are",
"correct",
".",
"The",
... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Base58.java#L170-L180 |
23,315 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Base58.java | Base58.divmod | private static byte divmod(byte[] number, int firstDigit, int base, int divisor) {
// this is just long division which accounts for the base of the input digits
int remainder = 0;
for (int i = firstDigit; i < number.length; i++) {
int digit = (int) number[i] & 0xFF;
int t... | java | private static byte divmod(byte[] number, int firstDigit, int base, int divisor) {
// this is just long division which accounts for the base of the input digits
int remainder = 0;
for (int i = firstDigit; i < number.length; i++) {
int digit = (int) number[i] & 0xFF;
int t... | [
"private",
"static",
"byte",
"divmod",
"(",
"byte",
"[",
"]",
"number",
",",
"int",
"firstDigit",
",",
"int",
"base",
",",
"int",
"divisor",
")",
"{",
"// this is just long division which accounts for the base of the input digits",
"int",
"remainder",
"=",
"0",
";",... | Divides a number, represented as an array of bytes each containing a single digit
in the specified base, by the given divisor. The given number is modified in-place
to contain the quotient, and the return value is the remainder.
@param number the number to divide
@param firstDigit the index within the array of the fir... | [
"Divides",
"a",
"number",
"represented",
"as",
"an",
"array",
"of",
"bytes",
"each",
"containing",
"a",
"single",
"digit",
"in",
"the",
"specified",
"base",
"by",
"the",
"given",
"divisor",
".",
"The",
"given",
"number",
"is",
"modified",
"in",
"-",
"place... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Base58.java#L194-L204 |
23,316 | bitcoinj/bitcoinj | tools/src/main/java/org/bitcoinj/tools/WalletTool.java | WalletTool.setup | private static void setup() throws BlockStoreException {
if (store != null) return; // Already done.
// Will create a fresh chain if one doesn't exist or there is an issue with this one.
boolean reset = !chainFileName.exists();
if (reset) {
// No chain, so reset the wallet a... | java | private static void setup() throws BlockStoreException {
if (store != null) return; // Already done.
// Will create a fresh chain if one doesn't exist or there is an issue with this one.
boolean reset = !chainFileName.exists();
if (reset) {
// No chain, so reset the wallet a... | [
"private",
"static",
"void",
"setup",
"(",
")",
"throws",
"BlockStoreException",
"{",
"if",
"(",
"store",
"!=",
"null",
")",
"return",
";",
"// Already done.",
"// Will create a fresh chain if one doesn't exist or there is an issue with this one.",
"boolean",
"reset",
"=",
... | Sets up all objects needed for network communication but does not bring up the peers. | [
"Sets",
"up",
"all",
"objects",
"needed",
"for",
"network",
"communication",
"but",
"does",
"not",
"bring",
"up",
"the",
"peers",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/tools/src/main/java/org/bitcoinj/tools/WalletTool.java#L1251-L1301 |
23,317 | bitcoinj/bitcoinj | tools/src/main/java/org/bitcoinj/tools/WalletTool.java | WalletTool.parseAsHexOrBase58 | private static byte[] parseAsHexOrBase58(String data) {
try {
return Utils.HEX.decode(data);
} catch (Exception e) {
// Didn't decode as hex, try base58.
try {
return Base58.decodeChecked(data);
} catch (AddressFormatException e1) {
... | java | private static byte[] parseAsHexOrBase58(String data) {
try {
return Utils.HEX.decode(data);
} catch (Exception e) {
// Didn't decode as hex, try base58.
try {
return Base58.decodeChecked(data);
} catch (AddressFormatException e1) {
... | [
"private",
"static",
"byte",
"[",
"]",
"parseAsHexOrBase58",
"(",
"String",
"data",
")",
"{",
"try",
"{",
"return",
"Utils",
".",
"HEX",
".",
"decode",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Didn't decode as hex, try base... | Attempts to parse the given string as arbitrary-length hex or base58 and then return the results, or null if
neither parse was successful. | [
"Attempts",
"to",
"parse",
"the",
"given",
"string",
"as",
"arbitrary",
"-",
"length",
"hex",
"or",
"base58",
"and",
"then",
"return",
"the",
"results",
"or",
"null",
"if",
"neither",
"parse",
"was",
"successful",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/tools/src/main/java/org/bitcoinj/tools/WalletTool.java#L1466-L1477 |
23,318 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java | ExponentialBackoff.trackFailure | public void trackFailure() {
retryTime = Utils.currentTimeMillis() + (long)backoff;
backoff = Math.min(backoff * params.multiplier, params.maximum);
} | java | public void trackFailure() {
retryTime = Utils.currentTimeMillis() + (long)backoff;
backoff = Math.min(backoff * params.multiplier, params.maximum);
} | [
"public",
"void",
"trackFailure",
"(",
")",
"{",
"retryTime",
"=",
"Utils",
".",
"currentTimeMillis",
"(",
")",
"+",
"(",
"long",
")",
"backoff",
";",
"backoff",
"=",
"Math",
".",
"min",
"(",
"backoff",
"*",
"params",
".",
"multiplier",
",",
"params",
... | Track a failure - multiply the back off interval by the multiplier | [
"Track",
"a",
"failure",
"-",
"multiply",
"the",
"back",
"off",
"interval",
"by",
"the",
"multiplier"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/ExponentialBackoff.java#L81-L84 |
23,319 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.polymod | private static int polymod(final byte[] values) {
int c = 1;
for (byte v_i: values) {
int c0 = (c >>> 25) & 0xff;
c = ((c & 0x1ffffff) << 5) ^ (v_i & 0xff);
if ((c0 & 1) != 0) c ^= 0x3b6a57b2;
if ((c0 & 2) != 0) c ^= 0x26508e6d;
if ((c0 & 4)... | java | private static int polymod(final byte[] values) {
int c = 1;
for (byte v_i: values) {
int c0 = (c >>> 25) & 0xff;
c = ((c & 0x1ffffff) << 5) ^ (v_i & 0xff);
if ((c0 & 1) != 0) c ^= 0x3b6a57b2;
if ((c0 & 2) != 0) c ^= 0x26508e6d;
if ((c0 & 4)... | [
"private",
"static",
"int",
"polymod",
"(",
"final",
"byte",
"[",
"]",
"values",
")",
"{",
"int",
"c",
"=",
"1",
";",
"for",
"(",
"byte",
"v_i",
":",
"values",
")",
"{",
"int",
"c0",
"=",
"(",
"c",
">>>",
"25",
")",
"&",
"0xff",
";",
"c",
"="... | Find the polynomial with value coefficients mod the generator as 30-bit. | [
"Find",
"the",
"polynomial",
"with",
"value",
"coefficients",
"mod",
"the",
"generator",
"as",
"30",
"-",
"bit",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L51-L63 |
23,320 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.expandHrp | private static byte[] expandHrp(final String hrp) {
int hrpLength = hrp.length();
byte ret[] = new byte[hrpLength * 2 + 1];
for (int i = 0; i < hrpLength; ++i) {
int c = hrp.charAt(i) & 0x7f; // Limit to standard 7-bit ASCII
ret[i] = (byte) ((c >>> 5) & 0x07);
... | java | private static byte[] expandHrp(final String hrp) {
int hrpLength = hrp.length();
byte ret[] = new byte[hrpLength * 2 + 1];
for (int i = 0; i < hrpLength; ++i) {
int c = hrp.charAt(i) & 0x7f; // Limit to standard 7-bit ASCII
ret[i] = (byte) ((c >>> 5) & 0x07);
... | [
"private",
"static",
"byte",
"[",
"]",
"expandHrp",
"(",
"final",
"String",
"hrp",
")",
"{",
"int",
"hrpLength",
"=",
"hrp",
".",
"length",
"(",
")",
";",
"byte",
"ret",
"[",
"]",
"=",
"new",
"byte",
"[",
"hrpLength",
"*",
"2",
"+",
"1",
"]",
";"... | Expand a HRP for use in checksum computation. | [
"Expand",
"a",
"HRP",
"for",
"use",
"in",
"checksum",
"computation",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L66-L76 |
23,321 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.verifyChecksum | private static boolean verifyChecksum(final String hrp, final byte[] values) {
byte[] hrpExpanded = expandHrp(hrp);
byte[] combined = new byte[hrpExpanded.length + values.length];
System.arraycopy(hrpExpanded, 0, combined, 0, hrpExpanded.length);
System.arraycopy(values, 0, combined, hrp... | java | private static boolean verifyChecksum(final String hrp, final byte[] values) {
byte[] hrpExpanded = expandHrp(hrp);
byte[] combined = new byte[hrpExpanded.length + values.length];
System.arraycopy(hrpExpanded, 0, combined, 0, hrpExpanded.length);
System.arraycopy(values, 0, combined, hrp... | [
"private",
"static",
"boolean",
"verifyChecksum",
"(",
"final",
"String",
"hrp",
",",
"final",
"byte",
"[",
"]",
"values",
")",
"{",
"byte",
"[",
"]",
"hrpExpanded",
"=",
"expandHrp",
"(",
"hrp",
")",
";",
"byte",
"[",
"]",
"combined",
"=",
"new",
"byt... | Verify a checksum. | [
"Verify",
"a",
"checksum",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L79-L85 |
23,322 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.createChecksum | private static byte[] createChecksum(final String hrp, final byte[] values) {
byte[] hrpExpanded = expandHrp(hrp);
byte[] enc = new byte[hrpExpanded.length + values.length + 6];
System.arraycopy(hrpExpanded, 0, enc, 0, hrpExpanded.length);
System.arraycopy(values, 0, enc, hrpExpanded.le... | java | private static byte[] createChecksum(final String hrp, final byte[] values) {
byte[] hrpExpanded = expandHrp(hrp);
byte[] enc = new byte[hrpExpanded.length + values.length + 6];
System.arraycopy(hrpExpanded, 0, enc, 0, hrpExpanded.length);
System.arraycopy(values, 0, enc, hrpExpanded.le... | [
"private",
"static",
"byte",
"[",
"]",
"createChecksum",
"(",
"final",
"String",
"hrp",
",",
"final",
"byte",
"[",
"]",
"values",
")",
"{",
"byte",
"[",
"]",
"hrpExpanded",
"=",
"expandHrp",
"(",
"hrp",
")",
";",
"byte",
"[",
"]",
"enc",
"=",
"new",
... | Create a checksum. | [
"Create",
"a",
"checksum",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L88-L99 |
23,323 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.encode | public static String encode(String hrp, final byte[] values) {
checkArgument(hrp.length() >= 1, "Human-readable part is too short");
checkArgument(hrp.length() <= 83, "Human-readable part is too long");
hrp = hrp.toLowerCase(Locale.ROOT);
byte[] checksum = createChecksum(hrp, values);
... | java | public static String encode(String hrp, final byte[] values) {
checkArgument(hrp.length() >= 1, "Human-readable part is too short");
checkArgument(hrp.length() <= 83, "Human-readable part is too long");
hrp = hrp.toLowerCase(Locale.ROOT);
byte[] checksum = createChecksum(hrp, values);
... | [
"public",
"static",
"String",
"encode",
"(",
"String",
"hrp",
",",
"final",
"byte",
"[",
"]",
"values",
")",
"{",
"checkArgument",
"(",
"hrp",
".",
"length",
"(",
")",
">=",
"1",
",",
"\"Human-readable part is too short\"",
")",
";",
"checkArgument",
"(",
... | Encode a Bech32 string. | [
"Encode",
"a",
"Bech32",
"string",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L107-L122 |
23,324 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Bech32.java | Bech32.decode | public static Bech32Data decode(final String str) throws AddressFormatException {
boolean lower = false, upper = false;
if (str.length() < 8)
throw new AddressFormatException.InvalidDataLength("Input too short: " + str.length());
if (str.length() > 90)
throw new AddressFo... | java | public static Bech32Data decode(final String str) throws AddressFormatException {
boolean lower = false, upper = false;
if (str.length() < 8)
throw new AddressFormatException.InvalidDataLength("Input too short: " + str.length());
if (str.length() > 90)
throw new AddressFo... | [
"public",
"static",
"Bech32Data",
"decode",
"(",
"final",
"String",
"str",
")",
"throws",
"AddressFormatException",
"{",
"boolean",
"lower",
"=",
"false",
",",
"upper",
"=",
"false",
";",
"if",
"(",
"str",
".",
"length",
"(",
")",
"<",
"8",
")",
"throw",... | Decode a Bech32 string. | [
"Decode",
"a",
"Bech32",
"string",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Bech32.java#L125-L158 |
23,325 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.isCoinBase | public boolean isCoinBase() {
return outpoint.getHash().equals(Sha256Hash.ZERO_HASH) &&
(outpoint.getIndex() & 0xFFFFFFFFL) == 0xFFFFFFFFL; // -1 but all is serialized to the wire as unsigned int.
} | java | public boolean isCoinBase() {
return outpoint.getHash().equals(Sha256Hash.ZERO_HASH) &&
(outpoint.getIndex() & 0xFFFFFFFFL) == 0xFFFFFFFFL; // -1 but all is serialized to the wire as unsigned int.
} | [
"public",
"boolean",
"isCoinBase",
"(",
")",
"{",
"return",
"outpoint",
".",
"getHash",
"(",
")",
".",
"equals",
"(",
"Sha256Hash",
".",
"ZERO_HASH",
")",
"&&",
"(",
"outpoint",
".",
"getIndex",
"(",
")",
"&",
"0xFFFFFFFF",
"L",
")",
"==",
"0xFFFFFFFF",
... | Coinbase transactions have special inputs with hashes of zero. If this is such an input, returns true. | [
"Coinbase",
"transactions",
"have",
"special",
"inputs",
"with",
"hashes",
"of",
"zero",
".",
"If",
"this",
"is",
"such",
"an",
"input",
"returns",
"true",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L182-L185 |
23,326 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.setScriptSig | public void setScriptSig(Script scriptSig) {
this.scriptSig = new WeakReference<>(checkNotNull(scriptSig));
// TODO: This should all be cleaned up so we have a consistent internal representation.
setScriptBytes(scriptSig.getProgram());
} | java | public void setScriptSig(Script scriptSig) {
this.scriptSig = new WeakReference<>(checkNotNull(scriptSig));
// TODO: This should all be cleaned up so we have a consistent internal representation.
setScriptBytes(scriptSig.getProgram());
} | [
"public",
"void",
"setScriptSig",
"(",
"Script",
"scriptSig",
")",
"{",
"this",
".",
"scriptSig",
"=",
"new",
"WeakReference",
"<>",
"(",
"checkNotNull",
"(",
"scriptSig",
")",
")",
";",
"// TODO: This should all be cleaned up so we have a consistent internal representati... | Set the given program as the scriptSig that is supposed to satisfy the connected output script. | [
"Set",
"the",
"given",
"program",
"as",
"the",
"scriptSig",
"that",
"is",
"supposed",
"to",
"satisfy",
"the",
"connected",
"output",
"script",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L203-L207 |
23,327 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.connect | public ConnectionResult connect(Map<Sha256Hash, Transaction> transactions, ConnectMode mode) {
Transaction tx = transactions.get(outpoint.getHash());
if (tx == null) {
return TransactionInput.ConnectionResult.NO_SUCH_TX;
}
return connect(tx, mode);
} | java | public ConnectionResult connect(Map<Sha256Hash, Transaction> transactions, ConnectMode mode) {
Transaction tx = transactions.get(outpoint.getHash());
if (tx == null) {
return TransactionInput.ConnectionResult.NO_SUCH_TX;
}
return connect(tx, mode);
} | [
"public",
"ConnectionResult",
"connect",
"(",
"Map",
"<",
"Sha256Hash",
",",
"Transaction",
">",
"transactions",
",",
"ConnectMode",
"mode",
")",
"{",
"Transaction",
"tx",
"=",
"transactions",
".",
"get",
"(",
"outpoint",
".",
"getHash",
"(",
")",
")",
";",
... | Connects this input to the relevant output of the referenced transaction if it's in the given map.
Connecting means updating the internal pointers and spent flags. If the mode is to ABORT_ON_CONFLICT then
the spent output won't be changed, but the outpoint.fromTx pointer will still be updated.
@param transactions Map ... | [
"Connects",
"this",
"input",
"to",
"the",
"relevant",
"output",
"of",
"the",
"referenced",
"transaction",
"if",
"it",
"s",
"in",
"the",
"given",
"map",
".",
"Connecting",
"means",
"updating",
"the",
"internal",
"pointers",
"and",
"spent",
"flags",
".",
"If",... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L351-L357 |
23,328 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.connect | public ConnectionResult connect(Transaction transaction, ConnectMode mode) {
if (!transaction.getTxId().equals(outpoint.getHash()))
return ConnectionResult.NO_SUCH_TX;
checkElementIndex((int) outpoint.getIndex(), transaction.getOutputs().size(), "Corrupt transaction");
TransactionOut... | java | public ConnectionResult connect(Transaction transaction, ConnectMode mode) {
if (!transaction.getTxId().equals(outpoint.getHash()))
return ConnectionResult.NO_SUCH_TX;
checkElementIndex((int) outpoint.getIndex(), transaction.getOutputs().size(), "Corrupt transaction");
TransactionOut... | [
"public",
"ConnectionResult",
"connect",
"(",
"Transaction",
"transaction",
",",
"ConnectMode",
"mode",
")",
"{",
"if",
"(",
"!",
"transaction",
".",
"getTxId",
"(",
")",
".",
"equals",
"(",
"outpoint",
".",
"getHash",
"(",
")",
")",
")",
"return",
"Connec... | Connects this input to the relevant output of the referenced transaction.
Connecting means updating the internal pointers and spent flags. If the mode is to ABORT_ON_CONFLICT then
the spent output won't be changed, but the outpoint.fromTx pointer will still be updated.
@param transaction The transaction to try.
@param... | [
"Connects",
"this",
"input",
"to",
"the",
"relevant",
"output",
"of",
"the",
"referenced",
"transaction",
".",
"Connecting",
"means",
"updating",
"the",
"internal",
"pointers",
"and",
"spent",
"flags",
".",
"If",
"the",
"mode",
"is",
"to",
"ABORT_ON_CONFLICT",
... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L368-L386 |
23,329 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.disconnect | public boolean disconnect() {
TransactionOutput connectedOutput;
if (outpoint.fromTx != null) {
// The outpoint is connected using a "standard" wallet, disconnect it.
connectedOutput = outpoint.fromTx.getOutput((int) outpoint.getIndex());
outpoint.fromTx = null;
... | java | public boolean disconnect() {
TransactionOutput connectedOutput;
if (outpoint.fromTx != null) {
// The outpoint is connected using a "standard" wallet, disconnect it.
connectedOutput = outpoint.fromTx.getOutput((int) outpoint.getIndex());
outpoint.fromTx = null;
... | [
"public",
"boolean",
"disconnect",
"(",
")",
"{",
"TransactionOutput",
"connectedOutput",
";",
"if",
"(",
"outpoint",
".",
"fromTx",
"!=",
"null",
")",
"{",
"// The outpoint is connected using a \"standard\" wallet, disconnect it.",
"connectedOutput",
"=",
"outpoint",
"."... | If this input is connected, check the output is connected back to this input and release it if so, making
it spendable once again.
@return true if the disconnection took place, false if it was not connected. | [
"If",
"this",
"input",
"is",
"connected",
"check",
"the",
"output",
"is",
"connected",
"back",
"to",
"this",
"input",
"and",
"release",
"it",
"if",
"so",
"making",
"it",
"spendable",
"once",
"again",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L401-L423 |
23,330 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.verify | public void verify() throws VerificationException {
final Transaction fromTx = getOutpoint().fromTx;
long spendingIndex = getOutpoint().getIndex();
checkNotNull(fromTx, "Not connected");
final TransactionOutput output = fromTx.getOutput((int) spendingIndex);
verify(output);
} | java | public void verify() throws VerificationException {
final Transaction fromTx = getOutpoint().fromTx;
long spendingIndex = getOutpoint().getIndex();
checkNotNull(fromTx, "Not connected");
final TransactionOutput output = fromTx.getOutput((int) spendingIndex);
verify(output);
} | [
"public",
"void",
"verify",
"(",
")",
"throws",
"VerificationException",
"{",
"final",
"Transaction",
"fromTx",
"=",
"getOutpoint",
"(",
")",
".",
"fromTx",
";",
"long",
"spendingIndex",
"=",
"getOutpoint",
"(",
")",
".",
"getIndex",
"(",
")",
";",
"checkNot... | For a connected transaction, runs the script against the connected pubkey and verifies they are correct.
@throws ScriptException if the script did not verify.
@throws VerificationException If the outpoint doesn't match the given output. | [
"For",
"a",
"connected",
"transaction",
"runs",
"the",
"script",
"against",
"the",
"connected",
"pubkey",
"and",
"verifies",
"they",
"are",
"correct",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L453-L459 |
23,331 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionInput.java | TransactionInput.verify | public void verify(TransactionOutput output) throws VerificationException {
if (output.parent != null) {
if (!getOutpoint().getHash().equals(output.getParentTransaction().getTxId()))
throw new VerificationException("This input does not refer to the tx containing the output.");
... | java | public void verify(TransactionOutput output) throws VerificationException {
if (output.parent != null) {
if (!getOutpoint().getHash().equals(output.getParentTransaction().getTxId()))
throw new VerificationException("This input does not refer to the tx containing the output.");
... | [
"public",
"void",
"verify",
"(",
"TransactionOutput",
"output",
")",
"throws",
"VerificationException",
"{",
"if",
"(",
"output",
".",
"parent",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"getOutpoint",
"(",
")",
".",
"getHash",
"(",
")",
".",
"equals",
"("... | Verifies that this input can spend the given output. Note that this input must be a part of a transaction.
Also note that the consistency of the outpoint will be checked, even if this input has not been connected.
@param output the output that this input is supposed to spend.
@throws ScriptException If the script does... | [
"Verifies",
"that",
"this",
"input",
"can",
"spend",
"the",
"given",
"output",
".",
"Note",
"that",
"this",
"input",
"must",
"be",
"a",
"part",
"of",
"a",
"transaction",
".",
"Also",
"note",
"that",
"the",
"consistency",
"of",
"the",
"outpoint",
"will",
... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionInput.java#L469-L479 |
23,332 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java | DeterministicSeed.getMnemonicString | @Nullable
public String getMnemonicString() {
return mnemonicCode != null ? Utils.SPACE_JOINER.join(mnemonicCode) : null;
} | java | @Nullable
public String getMnemonicString() {
return mnemonicCode != null ? Utils.SPACE_JOINER.join(mnemonicCode) : null;
} | [
"@",
"Nullable",
"public",
"String",
"getMnemonicString",
"(",
")",
"{",
"return",
"mnemonicCode",
"!=",
"null",
"?",
"Utils",
".",
"SPACE_JOINER",
".",
"join",
"(",
"mnemonicCode",
")",
":",
"null",
";",
"}"
] | Get the mnemonic code as string, or null if unknown. | [
"Get",
"the",
"mnemonic",
"code",
"as",
"string",
"or",
"null",
"if",
"unknown",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java#L251-L254 |
23,333 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java | TransactionOutPoint.getConnectedOutput | @Nullable
public TransactionOutput getConnectedOutput() {
if (fromTx != null) {
return fromTx.getOutputs().get((int) index);
} else if (connectedOutput != null) {
return connectedOutput;
}
return null;
} | java | @Nullable
public TransactionOutput getConnectedOutput() {
if (fromTx != null) {
return fromTx.getOutputs().get((int) index);
} else if (connectedOutput != null) {
return connectedOutput;
}
return null;
} | [
"@",
"Nullable",
"public",
"TransactionOutput",
"getConnectedOutput",
"(",
")",
"{",
"if",
"(",
"fromTx",
"!=",
"null",
")",
"{",
"return",
"fromTx",
".",
"getOutputs",
"(",
")",
".",
"get",
"(",
"(",
"int",
")",
"index",
")",
";",
"}",
"else",
"if",
... | An outpoint is a part of a transaction input that points to the output of another transaction. If we have both
sides in memory, and they have been linked together, this returns a pointer to the connected output, or null
if there is no such connection. | [
"An",
"outpoint",
"is",
"a",
"part",
"of",
"a",
"transaction",
"input",
"that",
"points",
"to",
"the",
"output",
"of",
"another",
"transaction",
".",
"If",
"we",
"have",
"both",
"sides",
"in",
"memory",
"and",
"they",
"have",
"been",
"linked",
"together",
... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java#L111-L119 |
23,334 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java | TransactionOutPoint.getConnectedRedeemData | @Nullable
public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException {
TransactionOutput connectedOutput = getConnectedOutput();
checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key");
Script connectedScript = connectedOutput.getScriptPubKey();
... | java | @Nullable
public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException {
TransactionOutput connectedOutput = getConnectedOutput();
checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key");
Script connectedScript = connectedOutput.getScriptPubKey();
... | [
"@",
"Nullable",
"public",
"RedeemData",
"getConnectedRedeemData",
"(",
"KeyBag",
"keyBag",
")",
"throws",
"ScriptException",
"{",
"TransactionOutput",
"connectedOutput",
"=",
"getConnectedOutput",
"(",
")",
";",
"checkNotNull",
"(",
"connectedOutput",
",",
"\"Input is ... | Returns the RedeemData identified in the connected output, for either P2PKH, P2WPKH, P2PK
or P2SH scripts.
If the script forms cannot be understood, throws ScriptException.
@return a RedeemData or null if the connected data cannot be found in the wallet. | [
"Returns",
"the",
"RedeemData",
"identified",
"in",
"the",
"connected",
"output",
"for",
"either",
"P2PKH",
"P2WPKH",
"P2PK",
"or",
"P2SH",
"scripts",
".",
"If",
"the",
"script",
"forms",
"cannot",
"be",
"understood",
"throws",
"ScriptException",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java#L165-L185 |
23,335 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.setMaxConnections | public void setMaxConnections(int maxConnections) {
int adjustment;
lock.lock();
try {
this.maxConnections = maxConnections;
if (!isRunning()) return;
} finally {
lock.unlock();
}
// We may now have too many or too few open connections.... | java | public void setMaxConnections(int maxConnections) {
int adjustment;
lock.lock();
try {
this.maxConnections = maxConnections;
if (!isRunning()) return;
} finally {
lock.unlock();
}
// We may now have too many or too few open connections.... | [
"public",
"void",
"setMaxConnections",
"(",
"int",
"maxConnections",
")",
"{",
"int",
"adjustment",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"maxConnections",
"=",
"maxConnections",
";",
"if",
"(",
"!",
"isRunning",
"(",
")",
")"... | Adjusts the desired number of connections that we will create to peers. Note that if there are already peers
open and the new value is lower than the current number of peers, those connections will be terminated. Likewise
if there aren't enough current connections to meet the new requested max size, some will be added. | [
"Adjusts",
"the",
"desired",
"number",
"of",
"connections",
"that",
"we",
"will",
"create",
"to",
"peers",
".",
"Note",
"that",
"if",
"there",
"are",
"already",
"peers",
"open",
"and",
"the",
"new",
"value",
"is",
"lower",
"than",
"the",
"current",
"number... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L391-L407 |
23,336 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.updateVersionMessageRelayTxesBeforeFilter | private void updateVersionMessageRelayTxesBeforeFilter(VersionMessage ver) {
// We will provide the remote node with a bloom filter (ie they shouldn't relay yet)
// if chain == null || !chain.shouldVerifyTransactions() and a wallet is added and bloom filters are enabled
// Note that the default ... | java | private void updateVersionMessageRelayTxesBeforeFilter(VersionMessage ver) {
// We will provide the remote node with a bloom filter (ie they shouldn't relay yet)
// if chain == null || !chain.shouldVerifyTransactions() and a wallet is added and bloom filters are enabled
// Note that the default ... | [
"private",
"void",
"updateVersionMessageRelayTxesBeforeFilter",
"(",
"VersionMessage",
"ver",
")",
"{",
"// We will provide the remote node with a bloom filter (ie they shouldn't relay yet)",
"// if chain == null || !chain.shouldVerifyTransactions() and a wallet is added and bloom filters are enab... | Updates the relayTxesBeforeFilter flag of ver | [
"Updates",
"the",
"relayTxesBeforeFilter",
"flag",
"of",
"ver"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L605-L617 |
23,337 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.addAddress | public void addAddress(PeerAddress peerAddress) {
int newMax;
lock.lock();
try {
if (addInactive(peerAddress)) {
newMax = getMaxConnections() + 1;
setMaxConnections(newMax);
}
} finally {
lock.unlock();
}
} | java | public void addAddress(PeerAddress peerAddress) {
int newMax;
lock.lock();
try {
if (addInactive(peerAddress)) {
newMax = getMaxConnections() + 1;
setMaxConnections(newMax);
}
} finally {
lock.unlock();
}
} | [
"public",
"void",
"addAddress",
"(",
"PeerAddress",
"peerAddress",
")",
"{",
"int",
"newMax",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"addInactive",
"(",
"peerAddress",
")",
")",
"{",
"newMax",
"=",
"getMaxConnections",
"(",
")",
... | Add an address to the list of potential peers to connect to. It won't necessarily be used unless there's a need
to build new connections to reach the max connection count.
@param peerAddress IP/port to use. | [
"Add",
"an",
"address",
"to",
"the",
"list",
"of",
"potential",
"peers",
"to",
"connect",
"to",
".",
"It",
"won",
"t",
"necessarily",
"be",
"used",
"unless",
"there",
"s",
"a",
"need",
"to",
"build",
"new",
"connections",
"to",
"reach",
"the",
"max",
"... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L857-L868 |
23,338 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.addInactive | private boolean addInactive(PeerAddress peerAddress) {
lock.lock();
try {
// Deduplicate
if (backoffMap.containsKey(peerAddress))
return false;
backoffMap.put(peerAddress, new ExponentialBackoff(peerBackoffParams));
inactives.offer(peerAddr... | java | private boolean addInactive(PeerAddress peerAddress) {
lock.lock();
try {
// Deduplicate
if (backoffMap.containsKey(peerAddress))
return false;
backoffMap.put(peerAddress, new ExponentialBackoff(peerBackoffParams));
inactives.offer(peerAddr... | [
"private",
"boolean",
"addInactive",
"(",
"PeerAddress",
"peerAddress",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"// Deduplicate",
"if",
"(",
"backoffMap",
".",
"containsKey",
"(",
"peerAddress",
")",
")",
"return",
"false",
";",
"backoffMap... | Returns true if it was added, false if it was already there. | [
"Returns",
"true",
"if",
"it",
"was",
"added",
"false",
"if",
"it",
"was",
"already",
"there",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L872-L884 |
23,339 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.setRequiredServices | public void setRequiredServices(long requiredServices) {
lock.lock();
try {
this.requiredServices = requiredServices;
peerDiscoverers.clear();
addPeerDiscovery(MultiplexingDiscovery.forServices(params, requiredServices));
} finally {
lock.unlock();... | java | public void setRequiredServices(long requiredServices) {
lock.lock();
try {
this.requiredServices = requiredServices;
peerDiscoverers.clear();
addPeerDiscovery(MultiplexingDiscovery.forServices(params, requiredServices));
} finally {
lock.unlock();... | [
"public",
"void",
"setRequiredServices",
"(",
"long",
"requiredServices",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"requiredServices",
"=",
"requiredServices",
";",
"peerDiscoverers",
".",
"clear",
"(",
")",
";",
"addPeerDiscovery... | Convenience for connecting only to peers that can serve specific services. It will configure suitable peer
discoveries.
@param requiredServices Required services as a bitmask, e.g. {@link VersionMessage#NODE_NETWORK}. | [
"Convenience",
"for",
"connecting",
"only",
"to",
"peers",
"that",
"can",
"serve",
"specific",
"services",
".",
"It",
"will",
"configure",
"suitable",
"peer",
"discoveries",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L891-L900 |
23,340 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.addPeerDiscovery | public void addPeerDiscovery(PeerDiscovery peerDiscovery) {
lock.lock();
try {
if (getMaxConnections() == 0)
setMaxConnections(DEFAULT_CONNECTIONS);
peerDiscoverers.add(peerDiscovery);
} finally {
lock.unlock();
}
} | java | public void addPeerDiscovery(PeerDiscovery peerDiscovery) {
lock.lock();
try {
if (getMaxConnections() == 0)
setMaxConnections(DEFAULT_CONNECTIONS);
peerDiscoverers.add(peerDiscovery);
} finally {
lock.unlock();
}
} | [
"public",
"void",
"addPeerDiscovery",
"(",
"PeerDiscovery",
"peerDiscovery",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"getMaxConnections",
"(",
")",
"==",
"0",
")",
"setMaxConnections",
"(",
"DEFAULT_CONNECTIONS",
")",
";",
"peerD... | Add addresses from a discovery source to the list of potential peers to connect to. If max connections has not
been configured, or set to zero, then it's set to the default at this point. | [
"Add",
"addresses",
"from",
"a",
"discovery",
"source",
"to",
"the",
"list",
"of",
"potential",
"peers",
"to",
"connect",
"to",
".",
"If",
"max",
"connections",
"has",
"not",
"been",
"configured",
"or",
"set",
"to",
"zero",
"then",
"it",
"s",
"set",
"to"... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L911-L920 |
23,341 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.discoverPeers | protected int discoverPeers() {
// Don't hold the lock whilst doing peer discovery: it can take a long time and cause high API latency.
checkState(!lock.isHeldByCurrentThread());
int maxPeersToDiscoverCount = this.vMaxPeersToDiscoverCount;
long peerDiscoveryTimeoutMillis = this.vPeerDisc... | java | protected int discoverPeers() {
// Don't hold the lock whilst doing peer discovery: it can take a long time and cause high API latency.
checkState(!lock.isHeldByCurrentThread());
int maxPeersToDiscoverCount = this.vMaxPeersToDiscoverCount;
long peerDiscoveryTimeoutMillis = this.vPeerDisc... | [
"protected",
"int",
"discoverPeers",
"(",
")",
"{",
"// Don't hold the lock whilst doing peer discovery: it can take a long time and cause high API latency.",
"checkState",
"(",
"!",
"lock",
".",
"isHeldByCurrentThread",
"(",
")",
")",
";",
"int",
"maxPeersToDiscoverCount",
"="... | Returns number of discovered peers. | [
"Returns",
"number",
"of",
"discovered",
"peers",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L923-L958 |
23,342 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.startAsync | public ListenableFuture startAsync() {
// This is run in a background thread by the Service implementation.
if (chain == null) {
// Just try to help catch what might be a programming error.
log.warn("Starting up with no attached block chain. Did you forget to pass one to the cons... | java | public ListenableFuture startAsync() {
// This is run in a background thread by the Service implementation.
if (chain == null) {
// Just try to help catch what might be a programming error.
log.warn("Starting up with no attached block chain. Did you forget to pass one to the cons... | [
"public",
"ListenableFuture",
"startAsync",
"(",
")",
"{",
"// This is run in a background thread by the Service implementation.",
"if",
"(",
"chain",
"==",
"null",
")",
"{",
"// Just try to help catch what might be a programming error.",
"log",
".",
"warn",
"(",
"\"Starting up... | Starts the PeerGroup and begins network activity.
@return A future that completes when first connection activity has been triggered (note: not first connection made). | [
"Starts",
"the",
"PeerGroup",
"and",
"begins",
"network",
"activity",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1012-L1037 |
23,343 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.stop | public void stop() {
try {
Stopwatch watch = Stopwatch.createStarted();
stopAsync();
log.info("Awaiting PeerGroup shutdown ...");
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
log.info("... took {}", watch);
} catch (InterruptedE... | java | public void stop() {
try {
Stopwatch watch = Stopwatch.createStarted();
stopAsync();
log.info("Awaiting PeerGroup shutdown ...");
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
log.info("... took {}", watch);
} catch (InterruptedE... | [
"public",
"void",
"stop",
"(",
")",
"{",
"try",
"{",
"Stopwatch",
"watch",
"=",
"Stopwatch",
".",
"createStarted",
"(",
")",
";",
"stopAsync",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"Awaiting PeerGroup shutdown ...\"",
")",
";",
"executor",
".",
"awaitT... | Does a blocking stop | [
"Does",
"a",
"blocking",
"stop"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1073-L1083 |
23,344 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.removeWallet | public void removeWallet(Wallet wallet) {
wallets.remove(checkNotNull(wallet));
peerFilterProviders.remove(wallet);
wallet.removeCoinsReceivedEventListener(walletCoinsReceivedEventListener);
wallet.removeKeyChainEventListener(walletKeyEventListener);
wallet.removeScriptsChangeEve... | java | public void removeWallet(Wallet wallet) {
wallets.remove(checkNotNull(wallet));
peerFilterProviders.remove(wallet);
wallet.removeCoinsReceivedEventListener(walletCoinsReceivedEventListener);
wallet.removeKeyChainEventListener(walletKeyEventListener);
wallet.removeScriptsChangeEve... | [
"public",
"void",
"removeWallet",
"(",
"Wallet",
"wallet",
")",
"{",
"wallets",
".",
"remove",
"(",
"checkNotNull",
"(",
"wallet",
")",
")",
";",
"peerFilterProviders",
".",
"remove",
"(",
"wallet",
")",
";",
"wallet",
".",
"removeCoinsReceivedEventListener",
... | Unlinks the given wallet so it no longer receives broadcast transactions or has its transactions announced. | [
"Unlinks",
"the",
"given",
"wallet",
"so",
"it",
"no",
"longer",
"receives",
"broadcast",
"transactions",
"or",
"has",
"its",
"transactions",
"announced",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1177-L1187 |
23,345 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.connectToLocalHost | @Nullable
public Peer connectToLocalHost() {
lock.lock();
try {
final PeerAddress localhost = PeerAddress.localhost(params);
backoffMap.put(localhost, new ExponentialBackoff(peerBackoffParams));
return connectTo(localhost, true, vConnectTimeoutMillis);
} f... | java | @Nullable
public Peer connectToLocalHost() {
lock.lock();
try {
final PeerAddress localhost = PeerAddress.localhost(params);
backoffMap.put(localhost, new ExponentialBackoff(peerBackoffParams));
return connectTo(localhost, true, vConnectTimeoutMillis);
} f... | [
"@",
"Nullable",
"public",
"Peer",
"connectToLocalHost",
"(",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"final",
"PeerAddress",
"localhost",
"=",
"PeerAddress",
".",
"localhost",
"(",
"params",
")",
";",
"backoffMap",
".",
"put",
"(",
"lo... | Helper for forcing a connection to localhost. Useful when using regtest mode. Returns the peer object. | [
"Helper",
"for",
"forcing",
"a",
"connection",
"to",
"localhost",
".",
"Useful",
"when",
"using",
"regtest",
"mode",
".",
"Returns",
"the",
"peer",
"object",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1322-L1332 |
23,346 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.connectTo | @Nullable @GuardedBy("lock")
protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections, int connectTimeoutMillis) {
checkState(lock.isHeldByCurrentThread());
VersionMessage ver = getVersionMessage().duplicate();
ver.bestHeight = chain == null ? 0 : chain.getBestChainHeigh... | java | @Nullable @GuardedBy("lock")
protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections, int connectTimeoutMillis) {
checkState(lock.isHeldByCurrentThread());
VersionMessage ver = getVersionMessage().duplicate();
ver.bestHeight = chain == null ? 0 : chain.getBestChainHeigh... | [
"@",
"Nullable",
"@",
"GuardedBy",
"(",
"\"lock\"",
")",
"protected",
"Peer",
"connectTo",
"(",
"PeerAddress",
"address",
",",
"boolean",
"incrementMaxConnections",
",",
"int",
"connectTimeoutMillis",
")",
"{",
"checkState",
"(",
"lock",
".",
"isHeldByCurrentThread"... | Creates a version message to send, constructs a Peer object and attempts to connect it. Returns the peer on
success or null on failure.
@param address Remote network address
@param incrementMaxConnections Whether to consider this connection an attempt to fill our quota, or something
explicitly requested.
@return Peer o... | [
"Creates",
"a",
"version",
"message",
"to",
"send",
"constructs",
"a",
"Peer",
"object",
"and",
"attempts",
"to",
"connect",
"it",
".",
"Returns",
"the",
"peer",
"on",
"success",
"or",
"null",
"on",
"failure",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1342-L1378 |
23,347 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.findPeersOfAtLeastVersion | public List<Peer> findPeersOfAtLeastVersion(long protocolVersion) {
lock.lock();
try {
ArrayList<Peer> results = new ArrayList<>(peers.size());
for (Peer peer : peers)
if (peer.getPeerVersionMessage().clientVersion >= protocolVersion)
results.a... | java | public List<Peer> findPeersOfAtLeastVersion(long protocolVersion) {
lock.lock();
try {
ArrayList<Peer> results = new ArrayList<>(peers.size());
for (Peer peer : peers)
if (peer.getPeerVersionMessage().clientVersion >= protocolVersion)
results.a... | [
"public",
"List",
"<",
"Peer",
">",
"findPeersOfAtLeastVersion",
"(",
"long",
"protocolVersion",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"ArrayList",
"<",
"Peer",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
"peers",
".",
"size",... | Returns an array list of peers that implement the given protocol version or better. | [
"Returns",
"an",
"array",
"list",
"of",
"peers",
"that",
"implement",
"the",
"given",
"protocol",
"version",
"or",
"better",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1920-L1931 |
23,348 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.findPeersWithServiceMask | public List<Peer> findPeersWithServiceMask(int mask) {
lock.lock();
try {
ArrayList<Peer> results = new ArrayList<>(peers.size());
for (Peer peer : peers)
if ((peer.getPeerVersionMessage().localServices & mask) == mask)
results.add(peer);
... | java | public List<Peer> findPeersWithServiceMask(int mask) {
lock.lock();
try {
ArrayList<Peer> results = new ArrayList<>(peers.size());
for (Peer peer : peers)
if ((peer.getPeerVersionMessage().localServices & mask) == mask)
results.add(peer);
... | [
"public",
"List",
"<",
"Peer",
">",
"findPeersWithServiceMask",
"(",
"int",
"mask",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"ArrayList",
"<",
"Peer",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
"peers",
".",
"size",
"(",
")"... | Returns an array list of peers that match the requested service bit mask. | [
"Returns",
"an",
"array",
"list",
"of",
"peers",
"that",
"match",
"the",
"requested",
"service",
"bit",
"mask",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1967-L1978 |
23,349 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Coin.java | Coin.valueOf | public static Coin valueOf(final int coins, final int cents) {
checkArgument(cents < 100);
checkArgument(cents >= 0);
checkArgument(coins >= 0);
final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents));
return coin;
} | java | public static Coin valueOf(final int coins, final int cents) {
checkArgument(cents < 100);
checkArgument(cents >= 0);
checkArgument(coins >= 0);
final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents));
return coin;
} | [
"public",
"static",
"Coin",
"valueOf",
"(",
"final",
"int",
"coins",
",",
"final",
"int",
"cents",
")",
"{",
"checkArgument",
"(",
"cents",
"<",
"100",
")",
";",
"checkArgument",
"(",
"cents",
">=",
"0",
")",
";",
"checkArgument",
"(",
"coins",
">=",
"... | Convert an amount expressed in the way humans are used to into satoshis. | [
"Convert",
"an",
"amount",
"expressed",
"in",
"the",
"way",
"humans",
"are",
"used",
"to",
"into",
"satoshis",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Coin.java#L109-L115 |
23,350 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/ListenerRegistration.java | ListenerRegistration.removeFromList | public static <T> boolean removeFromList(T listener, List<? extends ListenerRegistration<T>> list) {
checkNotNull(listener);
ListenerRegistration<T> item = null;
for (ListenerRegistration<T> registration : list) {
if (registration.listener == listener) {
item = regis... | java | public static <T> boolean removeFromList(T listener, List<? extends ListenerRegistration<T>> list) {
checkNotNull(listener);
ListenerRegistration<T> item = null;
for (ListenerRegistration<T> registration : list) {
if (registration.listener == listener) {
item = regis... | [
"public",
"static",
"<",
"T",
">",
"boolean",
"removeFromList",
"(",
"T",
"listener",
",",
"List",
"<",
"?",
"extends",
"ListenerRegistration",
"<",
"T",
">",
">",
"list",
")",
"{",
"checkNotNull",
"(",
"listener",
")",
";",
"ListenerRegistration",
"<",
"T... | Returns true if the listener was removed, else false. | [
"Returns",
"true",
"if",
"the",
"listener",
"was",
"removed",
"else",
"false",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/ListenerRegistration.java#L37-L48 |
23,351 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/FullPrunedBlockChain.java | FullPrunedBlockChain.disconnectTransactions | @Override
protected void disconnectTransactions(StoredBlock oldBlock) throws PrunedException, BlockStoreException {
checkState(lock.isHeldByCurrentThread());
blockStore.beginDatabaseBatchWrite();
try {
StoredUndoableBlock undoBlock = blockStore.getUndoBlock(oldBlock.getHeader().g... | java | @Override
protected void disconnectTransactions(StoredBlock oldBlock) throws PrunedException, BlockStoreException {
checkState(lock.isHeldByCurrentThread());
blockStore.beginDatabaseBatchWrite();
try {
StoredUndoableBlock undoBlock = blockStore.getUndoBlock(oldBlock.getHeader().g... | [
"@",
"Override",
"protected",
"void",
"disconnectTransactions",
"(",
"StoredBlock",
"oldBlock",
")",
"throws",
"PrunedException",
",",
"BlockStoreException",
"{",
"checkState",
"(",
"lock",
".",
"isHeldByCurrentThread",
"(",
")",
")",
";",
"blockStore",
".",
"beginD... | This is broken for blocks that do not pass BIP30, so all BIP30-failing blocks which are allowed to fail BIP30
must be checkpointed. | [
"This",
"is",
"broken",
"for",
"blocks",
"that",
"do",
"not",
"pass",
"BIP30",
"so",
"all",
"BIP30",
"-",
"failing",
"blocks",
"which",
"are",
"allowed",
"to",
"fail",
"BIP30",
"must",
"be",
"checkpointed",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/FullPrunedBlockChain.java#L496-L515 |
23,352 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/payments/PaymentSession.java | PaymentSession.getOutputs | public List<PaymentProtocol.Output> getOutputs() {
List<PaymentProtocol.Output> outputs = new ArrayList<>(paymentDetails.getOutputsCount());
for (Protos.Output output : paymentDetails.getOutputsList()) {
Coin amount = output.hasAmount() ? Coin.valueOf(output.getAmount()) : null;
... | java | public List<PaymentProtocol.Output> getOutputs() {
List<PaymentProtocol.Output> outputs = new ArrayList<>(paymentDetails.getOutputsCount());
for (Protos.Output output : paymentDetails.getOutputsList()) {
Coin amount = output.hasAmount() ? Coin.valueOf(output.getAmount()) : null;
... | [
"public",
"List",
"<",
"PaymentProtocol",
".",
"Output",
">",
"getOutputs",
"(",
")",
"{",
"List",
"<",
"PaymentProtocol",
".",
"Output",
">",
"outputs",
"=",
"new",
"ArrayList",
"<>",
"(",
"paymentDetails",
".",
"getOutputsCount",
"(",
")",
")",
";",
"for... | Returns the outputs of the payment request. | [
"Returns",
"the",
"outputs",
"of",
"the",
"payment",
"request",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/payments/PaymentSession.java#L226-L233 |
23,353 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TxConfidenceTable.java | TxConfidenceTable.cleanTable | private void cleanTable() {
lock.lock();
try {
Reference<? extends TransactionConfidence> ref;
while ((ref = referenceQueue.poll()) != null) {
// Find which transaction got deleted by the GC.
WeakConfidenceReference txRef = (WeakConfidenceReference... | java | private void cleanTable() {
lock.lock();
try {
Reference<? extends TransactionConfidence> ref;
while ((ref = referenceQueue.poll()) != null) {
// Find which transaction got deleted by the GC.
WeakConfidenceReference txRef = (WeakConfidenceReference... | [
"private",
"void",
"cleanTable",
"(",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"Reference",
"<",
"?",
"extends",
"TransactionConfidence",
">",
"ref",
";",
"while",
"(",
"(",
"ref",
"=",
"referenceQueue",
".",
"poll",
"(",
")",
")",
"... | If any transactions have expired due to being only weakly reachable through us, go ahead and delete their
table entries - it means we downloaded the transaction and sent it to various event listeners, none of
which bothered to keep a reference. Typically, this is because the transaction does not involve any keys that
a... | [
"If",
"any",
"transactions",
"have",
"expired",
"due",
"to",
"being",
"only",
"weakly",
"reachable",
"through",
"us",
"go",
"ahead",
"and",
"delete",
"their",
"table",
"entries",
"-",
"it",
"means",
"we",
"downloaded",
"the",
"transaction",
"and",
"sent",
"i... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TxConfidenceTable.java#L98-L111 |
23,354 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/TxConfidenceTable.java | TxConfidenceTable.numBroadcastPeers | public int numBroadcastPeers(Sha256Hash txHash) {
lock.lock();
try {
cleanTable();
WeakConfidenceReference entry = table.get(txHash);
if (entry == null) {
return 0; // No such TX known.
} else {
TransactionConfidence confid... | java | public int numBroadcastPeers(Sha256Hash txHash) {
lock.lock();
try {
cleanTable();
WeakConfidenceReference entry = table.get(txHash);
if (entry == null) {
return 0; // No such TX known.
} else {
TransactionConfidence confid... | [
"public",
"int",
"numBroadcastPeers",
"(",
"Sha256Hash",
"txHash",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"cleanTable",
"(",
")",
";",
"WeakConfidenceReference",
"entry",
"=",
"table",
".",
"get",
"(",
"txHash",
")",
";",
"if",
"(",
... | Returns the number of peers that have seen the given hash recently. | [
"Returns",
"the",
"number",
"of",
"peers",
"that",
"have",
"seen",
"the",
"given",
"hash",
"recently",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/TxConfidenceTable.java#L116-L136 |
23,355 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Sha256Hash.java | Sha256Hash.hash | public static byte[] hash(byte[] input, int offset, int length) {
MessageDigest digest = newDigest();
digest.update(input, offset, length);
return digest.digest();
} | java | public static byte[] hash(byte[] input, int offset, int length) {
MessageDigest digest = newDigest();
digest.update(input, offset, length);
return digest.digest();
} | [
"public",
"static",
"byte",
"[",
"]",
"hash",
"(",
"byte",
"[",
"]",
"input",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"MessageDigest",
"digest",
"=",
"newDigest",
"(",
")",
";",
"digest",
".",
"update",
"(",
"input",
",",
"offset",
",",... | Calculates the SHA-256 hash of the given byte range.
@param input the array containing the bytes to hash
@param offset the offset within the array of the bytes to hash
@param length the number of bytes to hash
@return the hash (in big-endian order) | [
"Calculates",
"the",
"SHA",
"-",
"256",
"hash",
"of",
"the",
"given",
"byte",
"range",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Sha256Hash.java#L166-L170 |
23,356 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/Sha256Hash.java | Sha256Hash.hashTwice | public static byte[] hashTwice(byte[] input, int offset, int length) {
MessageDigest digest = newDigest();
digest.update(input, offset, length);
return digest.digest(digest.digest());
} | java | public static byte[] hashTwice(byte[] input, int offset, int length) {
MessageDigest digest = newDigest();
digest.update(input, offset, length);
return digest.digest(digest.digest());
} | [
"public",
"static",
"byte",
"[",
"]",
"hashTwice",
"(",
"byte",
"[",
"]",
"input",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"MessageDigest",
"digest",
"=",
"newDigest",
"(",
")",
";",
"digest",
".",
"update",
"(",
"input",
",",
"offset",
... | Calculates the SHA-256 hash of the given byte range,
and then hashes the resulting hash again.
@param input the array containing the bytes to hash
@param offset the offset within the array of the bytes to hash
@param length the number of bytes to hash
@return the double-hash (in big-endian order) | [
"Calculates",
"the",
"SHA",
"-",
"256",
"hash",
"of",
"the",
"given",
"byte",
"range",
"and",
"then",
"hashes",
"the",
"resulting",
"hash",
"again",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/Sha256Hash.java#L203-L207 |
23,357 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/InventoryMessage.java | InventoryMessage.with | public static InventoryMessage with(Transaction... txns) {
checkArgument(txns.length > 0);
InventoryMessage result = new InventoryMessage(txns[0].getParams());
for (Transaction tx : txns)
result.addTransaction(tx);
return result;
} | java | public static InventoryMessage with(Transaction... txns) {
checkArgument(txns.length > 0);
InventoryMessage result = new InventoryMessage(txns[0].getParams());
for (Transaction tx : txns)
result.addTransaction(tx);
return result;
} | [
"public",
"static",
"InventoryMessage",
"with",
"(",
"Transaction",
"...",
"txns",
")",
"{",
"checkArgument",
"(",
"txns",
".",
"length",
">",
"0",
")",
";",
"InventoryMessage",
"result",
"=",
"new",
"InventoryMessage",
"(",
"txns",
"[",
"0",
"]",
".",
"ge... | Creates a new inv message for the given transactions. | [
"Creates",
"a",
"new",
"inv",
"message",
"for",
"the",
"given",
"transactions",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/InventoryMessage.java#L65-L71 |
23,358 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/net/discovery/SeedPeers.java | SeedPeers.getPeers | @Override
public InetSocketAddress[] getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
if (services != 0)
throw new PeerDiscoveryException("Pre-determined peers cannot be filtered by services: " + services);
try {
return allPeers... | java | @Override
public InetSocketAddress[] getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
if (services != 0)
throw new PeerDiscoveryException("Pre-determined peers cannot be filtered by services: " + services);
try {
return allPeers... | [
"@",
"Override",
"public",
"InetSocketAddress",
"[",
"]",
"getPeers",
"(",
"long",
"services",
",",
"long",
"timeoutValue",
",",
"TimeUnit",
"timeoutUnit",
")",
"throws",
"PeerDiscoveryException",
"{",
"if",
"(",
"services",
"!=",
"0",
")",
"throw",
"new",
"Pe... | Returns an array containing all the Bitcoin nodes within the list. | [
"Returns",
"an",
"array",
"containing",
"all",
"the",
"Bitcoin",
"nodes",
"within",
"the",
"list",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/net/discovery/SeedPeers.java#L87-L96 |
23,359 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/StoredBlock.java | StoredBlock.build | public StoredBlock build(Block block) throws VerificationException {
// Stored blocks track total work done in this chain, because the canonical chain is the one that represents
// the largest amount of work done not the tallest.
BigInteger chainWork = this.chainWork.add(block.getWork());
... | java | public StoredBlock build(Block block) throws VerificationException {
// Stored blocks track total work done in this chain, because the canonical chain is the one that represents
// the largest amount of work done not the tallest.
BigInteger chainWork = this.chainWork.add(block.getWork());
... | [
"public",
"StoredBlock",
"build",
"(",
"Block",
"block",
")",
"throws",
"VerificationException",
"{",
"// Stored blocks track total work done in this chain, because the canonical chain is the one that represents",
"// the largest amount of work done not the tallest.",
"BigInteger",
"chainW... | Creates a new StoredBlock, calculating the additional fields by adding to the values in this block. | [
"Creates",
"a",
"new",
"StoredBlock",
"calculating",
"the",
"additional",
"fields",
"by",
"adding",
"to",
"the",
"values",
"in",
"this",
"block",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/StoredBlock.java#L100-L106 |
23,360 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java | KeyCrypterScrypt.deriveKey | @Override
public KeyParameter deriveKey(CharSequence password) throws KeyCrypterException {
byte[] passwordBytes = null;
try {
passwordBytes = convertToByteArray(password);
byte[] salt = new byte[0];
if ( scryptParameters.getSalt() != null) {
salt ... | java | @Override
public KeyParameter deriveKey(CharSequence password) throws KeyCrypterException {
byte[] passwordBytes = null;
try {
passwordBytes = convertToByteArray(password);
byte[] salt = new byte[0];
if ( scryptParameters.getSalt() != null) {
salt ... | [
"@",
"Override",
"public",
"KeyParameter",
"deriveKey",
"(",
"CharSequence",
"password",
")",
"throws",
"KeyCrypterException",
"{",
"byte",
"[",
"]",
"passwordBytes",
"=",
"null",
";",
"try",
"{",
"passwordBytes",
"=",
"convertToByteArray",
"(",
"password",
")",
... | Generate AES key.
This is a very slow operation compared to encrypt/ decrypt so it is normally worth caching the result.
@param password The password to use in key generation
@return The KeyParameter containing the created AES key
@throws KeyCrypterException | [
"Generate",
"AES",
"key",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java#L145-L172 |
23,361 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java | KeyCrypterScrypt.encrypt | @Override
public EncryptedData encrypt(byte[] plainBytes, KeyParameter aesKey) throws KeyCrypterException {
checkNotNull(plainBytes);
checkNotNull(aesKey);
try {
// Generate iv - each encryption call has a different iv.
byte[] iv = new byte[BLOCK_LENGTH];
... | java | @Override
public EncryptedData encrypt(byte[] plainBytes, KeyParameter aesKey) throws KeyCrypterException {
checkNotNull(plainBytes);
checkNotNull(aesKey);
try {
// Generate iv - each encryption call has a different iv.
byte[] iv = new byte[BLOCK_LENGTH];
... | [
"@",
"Override",
"public",
"EncryptedData",
"encrypt",
"(",
"byte",
"[",
"]",
"plainBytes",
",",
"KeyParameter",
"aesKey",
")",
"throws",
"KeyCrypterException",
"{",
"checkNotNull",
"(",
"plainBytes",
")",
";",
"checkNotNull",
"(",
"aesKey",
")",
";",
"try",
"... | Password based encryption using AES - CBC 256 bits. | [
"Password",
"based",
"encryption",
"using",
"AES",
"-",
"CBC",
"256",
"bits",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java#L177-L200 |
23,362 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java | KeyCrypterScrypt.decrypt | @Override
public byte[] decrypt(EncryptedData dataToDecrypt, KeyParameter aesKey) throws KeyCrypterException {
checkNotNull(dataToDecrypt);
checkNotNull(aesKey);
try {
ParametersWithIV keyWithIv = new ParametersWithIV(new KeyParameter(aesKey.getKey()), dataToDecrypt.initialisati... | java | @Override
public byte[] decrypt(EncryptedData dataToDecrypt, KeyParameter aesKey) throws KeyCrypterException {
checkNotNull(dataToDecrypt);
checkNotNull(aesKey);
try {
ParametersWithIV keyWithIv = new ParametersWithIV(new KeyParameter(aesKey.getKey()), dataToDecrypt.initialisati... | [
"@",
"Override",
"public",
"byte",
"[",
"]",
"decrypt",
"(",
"EncryptedData",
"dataToDecrypt",
",",
"KeyParameter",
"aesKey",
")",
"throws",
"KeyCrypterException",
"{",
"checkNotNull",
"(",
"dataToDecrypt",
")",
";",
"checkNotNull",
"(",
"aesKey",
")",
";",
"try... | Decrypt bytes previously encrypted with this class.
@param dataToDecrypt The data to decrypt
@param aesKey The AES key to use for decryption
@return The decrypted bytes
@throws KeyCrypterException if bytes could not be decrypted | [
"Decrypt",
"bytes",
"previously",
"encrypted",
"with",
"this",
"class",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java#L210-L233 |
23,363 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/BriefLogFormatter.java | BriefLogFormatter.init | public static void init() {
logger = Logger.getLogger("");
final Handler[] handlers = logger.getHandlers();
// In regular Java there is always a handler. Avian doesn't install one however.
if (handlers.length > 0)
handlers[0].setFormatter(new BriefLogFormatter());
} | java | public static void init() {
logger = Logger.getLogger("");
final Handler[] handlers = logger.getHandlers();
// In regular Java there is always a handler. Avian doesn't install one however.
if (handlers.length > 0)
handlers[0].setFormatter(new BriefLogFormatter());
} | [
"public",
"static",
"void",
"init",
"(",
")",
"{",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"\"",
")",
";",
"final",
"Handler",
"[",
"]",
"handlers",
"=",
"logger",
".",
"getHandlers",
"(",
")",
";",
"// In regular Java there is always a handler. Avia... | Configures JDK logging to use this class for everything. | [
"Configures",
"JDK",
"logging",
"to",
"use",
"this",
"class",
"for",
"everything",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/BriefLogFormatter.java#L38-L44 |
23,364 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.fromID | @Nullable
public static NetworkParameters fromID(String id) {
if (id.equals(ID_MAINNET)) {
return MainNetParams.get();
} else if (id.equals(ID_TESTNET)) {
return TestNet3Params.get();
} else if (id.equals(ID_UNITTESTNET)) {
return UnitTestParams.get();
... | java | @Nullable
public static NetworkParameters fromID(String id) {
if (id.equals(ID_MAINNET)) {
return MainNetParams.get();
} else if (id.equals(ID_TESTNET)) {
return TestNet3Params.get();
} else if (id.equals(ID_UNITTESTNET)) {
return UnitTestParams.get();
... | [
"@",
"Nullable",
"public",
"static",
"NetworkParameters",
"fromID",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
".",
"equals",
"(",
"ID_MAINNET",
")",
")",
"{",
"return",
"MainNetParams",
".",
"get",
"(",
")",
";",
"}",
"else",
"if",
"(",
"id",
"... | Returns the network parameters for the given string ID or NULL if not recognized. | [
"Returns",
"the",
"network",
"parameters",
"for",
"the",
"given",
"string",
"ID",
"or",
"NULL",
"if",
"not",
"recognized",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L182-L195 |
23,365 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.fromPmtProtocolID | @Nullable
public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) {
if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) {
return MainNetParams.get();
} else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) {
return TestNet3Params.get();
} else... | java | @Nullable
public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) {
if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) {
return MainNetParams.get();
} else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) {
return TestNet3Params.get();
} else... | [
"@",
"Nullable",
"public",
"static",
"NetworkParameters",
"fromPmtProtocolID",
"(",
"String",
"pmtProtocolId",
")",
"{",
"if",
"(",
"pmtProtocolId",
".",
"equals",
"(",
"PAYMENT_PROTOCOL_ID_MAINNET",
")",
")",
"{",
"return",
"MainNetParams",
".",
"get",
"(",
")",
... | Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. | [
"Returns",
"the",
"network",
"parameters",
"for",
"the",
"given",
"string",
"paymentProtocolID",
"or",
"NULL",
"if",
"not",
"recognized",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L198-L211 |
23,366 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.passesCheckpoint | public boolean passesCheckpoint(int height, Sha256Hash hash) {
Sha256Hash checkpointHash = checkpoints.get(height);
return checkpointHash == null || checkpointHash.equals(hash);
} | java | public boolean passesCheckpoint(int height, Sha256Hash hash) {
Sha256Hash checkpointHash = checkpoints.get(height);
return checkpointHash == null || checkpointHash.equals(hash);
} | [
"public",
"boolean",
"passesCheckpoint",
"(",
"int",
"height",
",",
"Sha256Hash",
"hash",
")",
"{",
"Sha256Hash",
"checkpointHash",
"=",
"checkpoints",
".",
"get",
"(",
"height",
")",
";",
"return",
"checkpointHash",
"==",
"null",
"||",
"checkpointHash",
".",
... | Returns true if the block height is either not a checkpoint, or is a checkpoint and the hash matches. | [
"Returns",
"true",
"if",
"the",
"block",
"height",
"is",
"either",
"not",
"a",
"checkpoint",
"or",
"is",
"a",
"checkpoint",
"and",
"the",
"hash",
"matches",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L227-L230 |
23,367 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.getDefaultSerializer | public final MessageSerializer getDefaultSerializer() {
// Construct a default serializer if we don't have one
if (null == this.defaultSerializer) {
// Don't grab a lock unless we absolutely need it
synchronized(this) {
// Now we have a lock, double check there's ... | java | public final MessageSerializer getDefaultSerializer() {
// Construct a default serializer if we don't have one
if (null == this.defaultSerializer) {
// Don't grab a lock unless we absolutely need it
synchronized(this) {
// Now we have a lock, double check there's ... | [
"public",
"final",
"MessageSerializer",
"getDefaultSerializer",
"(",
")",
"{",
"// Construct a default serializer if we don't have one",
"if",
"(",
"null",
"==",
"this",
".",
"defaultSerializer",
")",
"{",
"// Don't grab a lock unless we absolutely need it",
"synchronized",
"("... | Return the default serializer for this network. This is a shared serializer.
@return the default serializer for this network. | [
"Return",
"the",
"default",
"serializer",
"for",
"this",
"network",
".",
"This",
"is",
"a",
"shared",
"serializer",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L397-L413 |
23,368 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.getBlockVerificationFlags | public EnumSet<Block.VerifyFlag> getBlockVerificationFlags(final Block block,
final VersionTally tally, final Integer height) {
final EnumSet<Block.VerifyFlag> flags = EnumSet.noneOf(Block.VerifyFlag.class);
if (block.isBIP34()) {
final Integer count = tally.getCountAtOrAbove(Bl... | java | public EnumSet<Block.VerifyFlag> getBlockVerificationFlags(final Block block,
final VersionTally tally, final Integer height) {
final EnumSet<Block.VerifyFlag> flags = EnumSet.noneOf(Block.VerifyFlag.class);
if (block.isBIP34()) {
final Integer count = tally.getCountAtOrAbove(Bl... | [
"public",
"EnumSet",
"<",
"Block",
".",
"VerifyFlag",
">",
"getBlockVerificationFlags",
"(",
"final",
"Block",
"block",
",",
"final",
"VersionTally",
"tally",
",",
"final",
"Integer",
"height",
")",
"{",
"final",
"EnumSet",
"<",
"Block",
".",
"VerifyFlag",
">"... | The flags indicating which block validation tests should be applied to
the given block. Enables support for alternative blockchains which enable
tests based on different criteria.
@param block block to determine flags for.
@param height height of the block, if known, null otherwise. Returned
tests should be a safe sub... | [
"The",
"flags",
"indicating",
"which",
"block",
"validation",
"tests",
"should",
"be",
"applied",
"to",
"the",
"given",
"block",
".",
"Enables",
"support",
"for",
"alternative",
"blockchains",
"which",
"enable",
"tests",
"based",
"on",
"different",
"criteria",
"... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L455-L466 |
23,369 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/NetworkParameters.java | NetworkParameters.getTransactionVerificationFlags | public EnumSet<Script.VerifyFlag> getTransactionVerificationFlags(final Block block,
final Transaction transaction, final VersionTally tally, final Integer height) {
final EnumSet<Script.VerifyFlag> verifyFlags = EnumSet.noneOf(Script.VerifyFlag.class);
if (block.getTimeSeconds() >= NetworkP... | java | public EnumSet<Script.VerifyFlag> getTransactionVerificationFlags(final Block block,
final Transaction transaction, final VersionTally tally, final Integer height) {
final EnumSet<Script.VerifyFlag> verifyFlags = EnumSet.noneOf(Script.VerifyFlag.class);
if (block.getTimeSeconds() >= NetworkP... | [
"public",
"EnumSet",
"<",
"Script",
".",
"VerifyFlag",
">",
"getTransactionVerificationFlags",
"(",
"final",
"Block",
"block",
",",
"final",
"Transaction",
"transaction",
",",
"final",
"VersionTally",
"tally",
",",
"final",
"Integer",
"height",
")",
"{",
"final",
... | The flags indicating which script validation tests should be applied to
the given transaction. Enables support for alternative blockchains which enable
tests based on different criteria.
@param block block the transaction belongs to.
@param transaction to determine flags for.
@param height height of the block, if know... | [
"The",
"flags",
"indicating",
"which",
"script",
"validation",
"tests",
"should",
"be",
"applied",
"to",
"the",
"given",
"transaction",
".",
"Enables",
"support",
"for",
"alternative",
"blockchains",
"which",
"enable",
"tests",
"based",
"on",
"different",
"criteri... | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/NetworkParameters.java#L478-L492 |
23,370 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/net/ProtobufConnection.java | ProtobufConnection.deserializeMessage | @SuppressWarnings("unchecked")
// The warning 'unchecked cast' being suppressed here comes from the build() formally returning
// a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.
private void deserializeMessage(ByteBuffer buff) throws Exception {
MessageType ms... | java | @SuppressWarnings("unchecked")
// The warning 'unchecked cast' being suppressed here comes from the build() formally returning
// a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.
private void deserializeMessage(ByteBuffer buff) throws Exception {
MessageType ms... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// The warning 'unchecked cast' being suppressed here comes from the build() formally returning",
"// a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.",
"private",
"void",
"deserializeMessage",
"(",
"By... | Does set the buffers's position to its limit | [
"Does",
"set",
"the",
"buffers",
"s",
"position",
"to",
"its",
"limit"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/net/ProtobufConnection.java#L127-L134 |
23,371 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoin/NativeSecp256k1.java | NativeSecp256k1.secKeyVerify | public static boolean secKeyVerify(byte[] seckey) {
Preconditions.checkArgument(seckey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seckey.length) {
byteBuff = ByteBuffer.allocateDirect(seckey.length);
byteBu... | java | public static boolean secKeyVerify(byte[] seckey) {
Preconditions.checkArgument(seckey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seckey.length) {
byteBuff = ByteBuffer.allocateDirect(seckey.length);
byteBu... | [
"public",
"static",
"boolean",
"secKeyVerify",
"(",
"byte",
"[",
"]",
"seckey",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"seckey",
".",
"length",
"==",
"32",
")",
";",
"ByteBuffer",
"byteBuff",
"=",
"nativeECDSABuffer",
".",
"get",
"(",
")",
"... | libsecp256k1 Seckey Verify - returns 1 if valid, 0 if invalid
@param seckey ECDSA Secret key, 32 bytes | [
"libsecp256k1",
"Seckey",
"Verify",
"-",
"returns",
"1",
"if",
"valid",
"0",
"if",
"invalid"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoin/NativeSecp256k1.java#L120-L138 |
23,372 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoin/NativeSecp256k1.java | NativeSecp256k1.privKeyTweakMul | public static byte[] privKeyTweakMul(byte[] privkey, byte[] tweak) throws AssertFailException {
Preconditions.checkArgument(privkey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < privkey.length + tweak.length) {
byteBuff =... | java | public static byte[] privKeyTweakMul(byte[] privkey, byte[] tweak) throws AssertFailException {
Preconditions.checkArgument(privkey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < privkey.length + tweak.length) {
byteBuff =... | [
"public",
"static",
"byte",
"[",
"]",
"privKeyTweakMul",
"(",
"byte",
"[",
"]",
"privkey",
",",
"byte",
"[",
"]",
"tweak",
")",
"throws",
"AssertFailException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"privkey",
".",
"length",
"==",
"32",
")",
";"... | libsecp256k1 PrivKey Tweak-Mul - Tweak privkey by multiplying to it
@param tweak some bytes to tweak with
@param privkey 32-byte seckey | [
"libsecp256k1",
"PrivKey",
"Tweak",
"-",
"Mul",
"-",
"Tweak",
"privkey",
"by",
"multiplying",
"to",
"it"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoin/NativeSecp256k1.java#L205-L236 |
23,373 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoin/NativeSecp256k1.java | NativeSecp256k1.pubKeyTweakAdd | public static byte[] pubKeyTweakAdd(byte[] pubkey, byte[] tweak) throws AssertFailException {
Preconditions.checkArgument(pubkey.length == 33 || pubkey.length == 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < pubkey.length + tweak.length) {
... | java | public static byte[] pubKeyTweakAdd(byte[] pubkey, byte[] tweak) throws AssertFailException {
Preconditions.checkArgument(pubkey.length == 33 || pubkey.length == 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < pubkey.length + tweak.length) {
... | [
"public",
"static",
"byte",
"[",
"]",
"pubKeyTweakAdd",
"(",
"byte",
"[",
"]",
"pubkey",
",",
"byte",
"[",
"]",
"tweak",
")",
"throws",
"AssertFailException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"pubkey",
".",
"length",
"==",
"33",
"||",
"pubk... | libsecp256k1 PubKey Tweak-Add - Tweak pubkey by adding to it
@param tweak some bytes to tweak with
@param pubkey 32-byte seckey | [
"libsecp256k1",
"PubKey",
"Tweak",
"-",
"Add",
"-",
"Tweak",
"pubkey",
"by",
"adding",
"to",
"it"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoin/NativeSecp256k1.java#L283-L314 |
23,374 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoin/NativeSecp256k1.java | NativeSecp256k1.createECDHSecret | public static byte[] createECDHSecret(byte[] seckey, byte[] pubkey) throws AssertFailException {
Preconditions.checkArgument(seckey.length <= 32 && pubkey.length <= 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < 32 + pubkey.length) {
... | java | public static byte[] createECDHSecret(byte[] seckey, byte[] pubkey) throws AssertFailException {
Preconditions.checkArgument(seckey.length <= 32 && pubkey.length <= 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < 32 + pubkey.length) {
... | [
"public",
"static",
"byte",
"[",
"]",
"createECDHSecret",
"(",
"byte",
"[",
"]",
"seckey",
",",
"byte",
"[",
"]",
"pubkey",
")",
"throws",
"AssertFailException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"seckey",
".",
"length",
"<=",
"32",
"&&",
"p... | libsecp256k1 create ECDH secret - constant time ECDH calculation
@param seckey byte array of secret key used in exponentiaion
@param pubkey byte array of public key used in exponentiaion | [
"libsecp256k1",
"create",
"ECDH",
"secret",
"-",
"constant",
"time",
"ECDH",
"calculation"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoin/NativeSecp256k1.java#L361-L389 |
23,375 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoin/NativeSecp256k1.java | NativeSecp256k1.randomize | public static synchronized boolean randomize(byte[] seed) throws AssertFailException {
Preconditions.checkArgument(seed.length == 32 || seed == null);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seed.length) {
byteBuff = ByteBuffer.al... | java | public static synchronized boolean randomize(byte[] seed) throws AssertFailException {
Preconditions.checkArgument(seed.length == 32 || seed == null);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seed.length) {
byteBuff = ByteBuffer.al... | [
"public",
"static",
"synchronized",
"boolean",
"randomize",
"(",
"byte",
"[",
"]",
"seed",
")",
"throws",
"AssertFailException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"seed",
".",
"length",
"==",
"32",
"||",
"seed",
"==",
"null",
")",
";",
"ByteBu... | libsecp256k1 randomize - updates the context randomization
@param seed 32-byte random seed | [
"libsecp256k1",
"randomize",
"-",
"updates",
"the",
"context",
"randomization"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoin/NativeSecp256k1.java#L396-L414 |
23,376 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java | PartialMerkleTree.buildFromLeaves | public static PartialMerkleTree buildFromLeaves(NetworkParameters params, byte[] includeBits, List<Sha256Hash> allLeafHashes) {
// Calculate height of the tree.
int height = 0;
while (getTreeWidth(allLeafHashes.size(), height) > 1)
height++;
List<Boolean> bitList = new ArrayL... | java | public static PartialMerkleTree buildFromLeaves(NetworkParameters params, byte[] includeBits, List<Sha256Hash> allLeafHashes) {
// Calculate height of the tree.
int height = 0;
while (getTreeWidth(allLeafHashes.size(), height) > 1)
height++;
List<Boolean> bitList = new ArrayL... | [
"public",
"static",
"PartialMerkleTree",
"buildFromLeaves",
"(",
"NetworkParameters",
"params",
",",
"byte",
"[",
"]",
"includeBits",
",",
"List",
"<",
"Sha256Hash",
">",
"allLeafHashes",
")",
"{",
"// Calculate height of the tree.",
"int",
"height",
"=",
"0",
";",
... | Calculates a PMT given the list of leaf hashes and which leaves need to be included. The relevant interior hashes
are calculated and a new PMT returned. | [
"Calculates",
"a",
"PMT",
"given",
"the",
"list",
"of",
"leaf",
"hashes",
"and",
"which",
"leaves",
"need",
"to",
"be",
"included",
".",
"The",
"relevant",
"interior",
"hashes",
"are",
"calculated",
"and",
"a",
"new",
"PMT",
"returned",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java#L89-L102 |
23,377 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java | PartialMerkleTree.recursiveExtractHashes | private Sha256Hash recursiveExtractHashes(int height, int pos, ValuesUsed used, List<Sha256Hash> matchedHashes) throws VerificationException {
if (used.bitsUsed >= matchedChildBits.length*8) {
// overflowed the bits array - failure
throw new VerificationException("PartialMerkleTree overf... | java | private Sha256Hash recursiveExtractHashes(int height, int pos, ValuesUsed used, List<Sha256Hash> matchedHashes) throws VerificationException {
if (used.bitsUsed >= matchedChildBits.length*8) {
// overflowed the bits array - failure
throw new VerificationException("PartialMerkleTree overf... | [
"private",
"Sha256Hash",
"recursiveExtractHashes",
"(",
"int",
"height",
",",
"int",
"pos",
",",
"ValuesUsed",
"used",
",",
"List",
"<",
"Sha256Hash",
">",
"matchedHashes",
")",
"throws",
"VerificationException",
"{",
"if",
"(",
"used",
".",
"bitsUsed",
">=",
... | it returns the hash of the respective node. | [
"it",
"returns",
"the",
"hash",
"of",
"the",
"respective",
"node",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java#L186-L215 |
23,378 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java | PartialMerkleTree.getTxnHashAndMerkleRoot | public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashesOut) throws VerificationException {
matchedHashesOut.clear();
// An empty set will not work
if (transactionCount == 0)
throw new VerificationException("Got a CPartialMerkleTree with 0 transactions");
... | java | public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashesOut) throws VerificationException {
matchedHashesOut.clear();
// An empty set will not work
if (transactionCount == 0)
throw new VerificationException("Got a CPartialMerkleTree with 0 transactions");
... | [
"public",
"Sha256Hash",
"getTxnHashAndMerkleRoot",
"(",
"List",
"<",
"Sha256Hash",
">",
"matchedHashesOut",
")",
"throws",
"VerificationException",
"{",
"matchedHashesOut",
".",
"clear",
"(",
")",
";",
"// An empty set will not work",
"if",
"(",
"transactionCount",
"=="... | Extracts tx hashes that are in this merkle tree
and returns the merkle root of this tree.
The returned root should be checked against the
merkle root contained in the block header for security.
@param matchedHashesOut A list which will contain the matched txn (will be cleared).
@return the merkle root of this merkle ... | [
"Extracts",
"tx",
"hashes",
"that",
"are",
"in",
"this",
"merkle",
"tree",
"and",
"returns",
"the",
"merkle",
"root",
"of",
"this",
"tree",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java#L232-L261 |
23,379 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelV1ServerState.java | PaymentChannelV1ServerState.getRefundTransactionUnlockTime | public synchronized long getRefundTransactionUnlockTime() {
checkState(getState().compareTo(State.WAITING_FOR_MULTISIG_CONTRACT) > 0 && getState() != State.ERROR);
return refundTransactionUnlockTimeSecs;
} | java | public synchronized long getRefundTransactionUnlockTime() {
checkState(getState().compareTo(State.WAITING_FOR_MULTISIG_CONTRACT) > 0 && getState() != State.ERROR);
return refundTransactionUnlockTimeSecs;
} | [
"public",
"synchronized",
"long",
"getRefundTransactionUnlockTime",
"(",
")",
"{",
"checkState",
"(",
"getState",
"(",
")",
".",
"compareTo",
"(",
"State",
".",
"WAITING_FOR_MULTISIG_CONTRACT",
")",
">",
"0",
"&&",
"getState",
"(",
")",
"!=",
"State",
".",
"ER... | Gets the client's refund transaction which they can spend to get the entire channel value back if it reaches its
lock time. | [
"Gets",
"the",
"client",
"s",
"refund",
"transaction",
"which",
"they",
"can",
"spend",
"to",
"get",
"the",
"entire",
"channel",
"value",
"back",
"if",
"it",
"reaches",
"its",
"lock",
"time",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelV1ServerState.java#L282-L285 |
23,380 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServer.java | PaymentChannelServer.receiveMessage | public void receiveMessage(Protos.TwoWayChannelMessage msg) {
lock.lock();
try {
checkState(connectionOpen);
if (channelSettling)
return;
try {
switch (msg.getType()) {
case CLIENT_VERSION:
re... | java | public void receiveMessage(Protos.TwoWayChannelMessage msg) {
lock.lock();
try {
checkState(connectionOpen);
if (channelSettling)
return;
try {
switch (msg.getType()) {
case CLIENT_VERSION:
re... | [
"public",
"void",
"receiveMessage",
"(",
"Protos",
".",
"TwoWayChannelMessage",
"msg",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"checkState",
"(",
"connectionOpen",
")",
";",
"if",
"(",
"channelSettling",
")",
"return",
";",
"try",
"{",
... | Called when a message is received from the client. Processes the given message and generates events based on its
content. | [
"Called",
"when",
"a",
"message",
"is",
"received",
"from",
"the",
"client",
".",
"Processes",
"the",
"given",
"message",
"and",
"generates",
"events",
"based",
"on",
"its",
"content",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServer.java#L475-L525 |
23,381 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServerListener.java | PaymentChannelServerListener.bindAndStart | public void bindAndStart(int port) throws Exception {
server = new NioServer(new StreamConnectionFactory() {
@Override
public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
return new ServerHandler(new InetSocketAddre... | java | public void bindAndStart(int port) throws Exception {
server = new NioServer(new StreamConnectionFactory() {
@Override
public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
return new ServerHandler(new InetSocketAddre... | [
"public",
"void",
"bindAndStart",
"(",
"int",
"port",
")",
"throws",
"Exception",
"{",
"server",
"=",
"new",
"NioServer",
"(",
"new",
"StreamConnectionFactory",
"(",
")",
"{",
"@",
"Override",
"public",
"ProtobufConnection",
"<",
"Protos",
".",
"TwoWayChannelMes... | Binds to the given port and starts accepting new client connections.
@throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) | [
"Binds",
"to",
"the",
"given",
"port",
"and",
"starts",
"accepting",
"new",
"client",
"connections",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServerListener.java#L152-L161 |
23,382 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/net/ConnectionHandler.java | ConnectionHandler.closeConnection | @Override
public void closeConnection() {
checkState(!lock.isHeldByCurrentThread());
try {
channel.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
connectionClosed();
} | java | @Override
public void closeConnection() {
checkState(!lock.isHeldByCurrentThread());
try {
channel.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
connectionClosed();
} | [
"@",
"Override",
"public",
"void",
"closeConnection",
"(",
")",
"{",
"checkState",
"(",
"!",
"lock",
".",
"isHeldByCurrentThread",
"(",
")",
")",
";",
"try",
"{",
"channel",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
... | May NOT be called with lock held | [
"May",
"NOT",
"be",
"called",
"with",
"lock",
"held"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/net/ConnectionHandler.java#L172-L181 |
23,383 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/net/ConnectionHandler.java | ConnectionHandler.handleKey | public static void handleKey(SelectionKey key) {
ConnectionHandler handler = ((ConnectionHandler)key.attachment());
try {
if (handler == null)
return;
if (!key.isValid()) {
handler.closeConnection(); // Key has been cancelled, make sure the socket ... | java | public static void handleKey(SelectionKey key) {
ConnectionHandler handler = ((ConnectionHandler)key.attachment());
try {
if (handler == null)
return;
if (!key.isValid()) {
handler.closeConnection(); // Key has been cancelled, make sure the socket ... | [
"public",
"static",
"void",
"handleKey",
"(",
"SelectionKey",
"key",
")",
"{",
"ConnectionHandler",
"handler",
"=",
"(",
"(",
"ConnectionHandler",
")",
"key",
".",
"attachment",
"(",
")",
")",
";",
"try",
"{",
"if",
"(",
"handler",
"==",
"null",
")",
"re... | atomically for a given ConnectionHandler) | [
"atomically",
"for",
"a",
"given",
"ConnectionHandler",
")"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/net/ConnectionHandler.java#L201-L238 |
23,384 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getProgram | public byte[] getProgram() {
try {
// Don't round-trip as Bitcoin Core doesn't and it would introduce a mismatch.
if (program != null)
return Arrays.copyOf(program, program.length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
for (Scri... | java | public byte[] getProgram() {
try {
// Don't round-trip as Bitcoin Core doesn't and it would introduce a mismatch.
if (program != null)
return Arrays.copyOf(program, program.length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
for (Scri... | [
"public",
"byte",
"[",
"]",
"getProgram",
"(",
")",
"{",
"try",
"{",
"// Don't round-trip as Bitcoin Core doesn't and it would introduce a mismatch.",
"if",
"(",
"program",
"!=",
"null",
")",
"return",
"Arrays",
".",
"copyOf",
"(",
"program",
",",
"program",
".",
... | Returns the serialized program as a newly created byte array. | [
"Returns",
"the",
"serialized",
"program",
"as",
"a",
"newly",
"created",
"byte",
"array",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L157-L171 |
23,385 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getToAddress | public Address getToAddress(NetworkParameters params, boolean forcePayToPubKey) throws ScriptException {
if (ScriptPattern.isP2PKH(this))
return LegacyAddress.fromPubKeyHash(params, ScriptPattern.extractHashFromP2PKH(this));
else if (ScriptPattern.isP2SH(this))
return LegacyAddre... | java | public Address getToAddress(NetworkParameters params, boolean forcePayToPubKey) throws ScriptException {
if (ScriptPattern.isP2PKH(this))
return LegacyAddress.fromPubKeyHash(params, ScriptPattern.extractHashFromP2PKH(this));
else if (ScriptPattern.isP2SH(this))
return LegacyAddre... | [
"public",
"Address",
"getToAddress",
"(",
"NetworkParameters",
"params",
",",
"boolean",
"forcePayToPubKey",
")",
"throws",
"ScriptException",
"{",
"if",
"(",
"ScriptPattern",
".",
"isP2PKH",
"(",
"this",
")",
")",
"return",
"LegacyAddress",
".",
"fromPubKeyHash",
... | Gets the destination address from this script, if it's in the required form.
@param forcePayToPubKey
If true, allow payToPubKey to be casted to the corresponding address. This is useful if you prefer
showing addresses rather than pubkeys. | [
"Gets",
"the",
"destination",
"address",
"from",
"this",
"script",
"if",
"it",
"s",
"in",
"the",
"required",
"form",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L301-L312 |
23,386 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getScriptSigWithSignature | public Script getScriptSigWithSignature(Script scriptSig, byte[] sigBytes, int index) {
int sigsPrefixCount = 0;
int sigsSuffixCount = 0;
if (ScriptPattern.isP2SH(this)) {
sigsPrefixCount = 1; // OP_0 <sig>* <redeemScript>
sigsSuffixCount = 1;
} else if (ScriptPat... | java | public Script getScriptSigWithSignature(Script scriptSig, byte[] sigBytes, int index) {
int sigsPrefixCount = 0;
int sigsSuffixCount = 0;
if (ScriptPattern.isP2SH(this)) {
sigsPrefixCount = 1; // OP_0 <sig>* <redeemScript>
sigsSuffixCount = 1;
} else if (ScriptPat... | [
"public",
"Script",
"getScriptSigWithSignature",
"(",
"Script",
"scriptSig",
",",
"byte",
"[",
"]",
"sigBytes",
",",
"int",
"index",
")",
"{",
"int",
"sigsPrefixCount",
"=",
"0",
";",
"int",
"sigsSuffixCount",
"=",
"0",
";",
"if",
"(",
"ScriptPattern",
".",
... | Returns a copy of the given scriptSig with the signature inserted in the given position. | [
"Returns",
"a",
"copy",
"of",
"the",
"given",
"scriptSig",
"with",
"the",
"signature",
"inserted",
"in",
"the",
"given",
"position",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L419-L431 |
23,387 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getSigInsertionIndex | public int getSigInsertionIndex(Sha256Hash hash, ECKey signingKey) {
// Iterate over existing signatures, skipping the initial OP_0, the final redeem script
// and any placeholder OP_0 sigs.
List<ScriptChunk> existingChunks = chunks.subList(1, chunks.size() - 1);
ScriptChunk redeemScript... | java | public int getSigInsertionIndex(Sha256Hash hash, ECKey signingKey) {
// Iterate over existing signatures, skipping the initial OP_0, the final redeem script
// and any placeholder OP_0 sigs.
List<ScriptChunk> existingChunks = chunks.subList(1, chunks.size() - 1);
ScriptChunk redeemScript... | [
"public",
"int",
"getSigInsertionIndex",
"(",
"Sha256Hash",
"hash",
",",
"ECKey",
"signingKey",
")",
"{",
"// Iterate over existing signatures, skipping the initial OP_0, the final redeem script",
"// and any placeholder OP_0 sigs.",
"List",
"<",
"ScriptChunk",
">",
"existingChunks... | Returns the index where a signature by the key should be inserted. Only applicable to
a P2SH scriptSig. | [
"Returns",
"the",
"index",
"where",
"a",
"signature",
"by",
"the",
"key",
"should",
"be",
"inserted",
".",
"Only",
"applicable",
"to",
"a",
"P2SH",
"scriptSig",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L438-L463 |
23,388 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getPubKeys | public List<ECKey> getPubKeys() {
if (!ScriptPattern.isSentToMultisig(this))
throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Only usable for multisig scripts.");
ArrayList<ECKey> result = Lists.newArrayList();
int numKeys = Script.decodeFromOpN(chunks.get(chunks.siz... | java | public List<ECKey> getPubKeys() {
if (!ScriptPattern.isSentToMultisig(this))
throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Only usable for multisig scripts.");
ArrayList<ECKey> result = Lists.newArrayList();
int numKeys = Script.decodeFromOpN(chunks.get(chunks.siz... | [
"public",
"List",
"<",
"ECKey",
">",
"getPubKeys",
"(",
")",
"{",
"if",
"(",
"!",
"ScriptPattern",
".",
"isSentToMultisig",
"(",
"this",
")",
")",
"throw",
"new",
"ScriptException",
"(",
"ScriptError",
".",
"SCRIPT_ERR_UNKNOWN_ERROR",
",",
"\"Only usable for mul... | Returns a list of the keys required by this script, assuming a multi-sig script.
@throws ScriptException if the script type is not understood or is pay to address or is P2SH (run this method on the "Redeem script" instead). | [
"Returns",
"a",
"list",
"of",
"the",
"keys",
"required",
"by",
"this",
"script",
"assuming",
"a",
"multi",
"-",
"sig",
"script",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L482-L491 |
23,389 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getP2SHSigOpCount | public static long getP2SHSigOpCount(byte[] scriptSig) throws ScriptException {
Script script = new Script();
try {
script.parse(scriptSig);
} catch (ScriptException e) {
// Ignore errors and count up to the parse-able length
}
for (int i = script.chunks.s... | java | public static long getP2SHSigOpCount(byte[] scriptSig) throws ScriptException {
Script script = new Script();
try {
script.parse(scriptSig);
} catch (ScriptException e) {
// Ignore errors and count up to the parse-able length
}
for (int i = script.chunks.s... | [
"public",
"static",
"long",
"getP2SHSigOpCount",
"(",
"byte",
"[",
"]",
"scriptSig",
")",
"throws",
"ScriptException",
"{",
"Script",
"script",
"=",
"new",
"Script",
"(",
")",
";",
"try",
"{",
"script",
".",
"parse",
"(",
"scriptSig",
")",
";",
"}",
"cat... | Gets the count of P2SH Sig Ops in the Script scriptSig | [
"Gets",
"the",
"count",
"of",
"P2SH",
"Sig",
"Ops",
"in",
"the",
"Script",
"scriptSig"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L573-L587 |
23,390 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getNumberOfSignaturesRequiredToSpend | public int getNumberOfSignaturesRequiredToSpend() {
if (ScriptPattern.isSentToMultisig(this)) {
// for N of M CHECKMULTISIG script we will need N signatures to spend
ScriptChunk nChunk = chunks.get(0);
return Script.decodeFromOpN(nChunk.opcode);
} else if (ScriptPatte... | java | public int getNumberOfSignaturesRequiredToSpend() {
if (ScriptPattern.isSentToMultisig(this)) {
// for N of M CHECKMULTISIG script we will need N signatures to spend
ScriptChunk nChunk = chunks.get(0);
return Script.decodeFromOpN(nChunk.opcode);
} else if (ScriptPatte... | [
"public",
"int",
"getNumberOfSignaturesRequiredToSpend",
"(",
")",
"{",
"if",
"(",
"ScriptPattern",
".",
"isSentToMultisig",
"(",
"this",
")",
")",
"{",
"// for N of M CHECKMULTISIG script we will need N signatures to spend",
"ScriptChunk",
"nChunk",
"=",
"chunks",
".",
"... | Returns number of signatures required to satisfy this script. | [
"Returns",
"number",
"of",
"signatures",
"required",
"to",
"satisfy",
"this",
"script",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L592-L605 |
23,391 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.removeAllInstancesOf | public static byte[] removeAllInstancesOf(byte[] inputScript, byte[] chunkToRemove) {
// We usually don't end up removing anything
UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(inputScript.length);
int cursor = 0;
while (cursor < inputScript.length) {
boo... | java | public static byte[] removeAllInstancesOf(byte[] inputScript, byte[] chunkToRemove) {
// We usually don't end up removing anything
UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(inputScript.length);
int cursor = 0;
while (cursor < inputScript.length) {
boo... | [
"public",
"static",
"byte",
"[",
"]",
"removeAllInstancesOf",
"(",
"byte",
"[",
"]",
"inputScript",
",",
"byte",
"[",
"]",
"chunkToRemove",
")",
"{",
"// We usually don't end up removing anything",
"UnsafeByteArrayOutputStream",
"bos",
"=",
"new",
"UnsafeByteArrayOutput... | Returns the script bytes of inputScript with all instances of the specified script object removed | [
"Returns",
"the",
"script",
"bytes",
"of",
"inputScript",
"with",
"all",
"instances",
"of",
"the",
"specified",
"script",
"object",
"removed"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L666-L696 |
23,392 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.executeCheckLockTimeVerify | private static void executeCheckLockTimeVerify(Transaction txContainingThis, int index, LinkedList<byte[]> stack, Set<VerifyFlag> verifyFlags) throws ScriptException {
if (stack.size() < 1)
throw new ScriptException(ScriptError.SCRIPT_ERR_INVALID_STACK_OPERATION, "Attempted OP_CHECKLOCKTIMEVERIFY on... | java | private static void executeCheckLockTimeVerify(Transaction txContainingThis, int index, LinkedList<byte[]> stack, Set<VerifyFlag> verifyFlags) throws ScriptException {
if (stack.size() < 1)
throw new ScriptException(ScriptError.SCRIPT_ERR_INVALID_STACK_OPERATION, "Attempted OP_CHECKLOCKTIMEVERIFY on... | [
"private",
"static",
"void",
"executeCheckLockTimeVerify",
"(",
"Transaction",
"txContainingThis",
",",
"int",
"index",
",",
"LinkedList",
"<",
"byte",
"[",
"]",
">",
"stack",
",",
"Set",
"<",
"VerifyFlag",
">",
"verifyFlags",
")",
"throws",
"ScriptException",
"... | This is more or less a direct translation of the code in Bitcoin Core | [
"This",
"is",
"more",
"or",
"less",
"a",
"direct",
"translation",
"of",
"the",
"code",
"in",
"Bitcoin",
"Core"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L1305-L1340 |
23,393 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/ScriptOpCodes.java | ScriptOpCodes.getOpCode | public static int getOpCode(String opCodeName) {
if (opCodeNameMap.containsKey(opCodeName))
return opCodeNameMap.get(opCodeName);
return OP_INVALIDOPCODE;
} | java | public static int getOpCode(String opCodeName) {
if (opCodeNameMap.containsKey(opCodeName))
return opCodeNameMap.get(opCodeName);
return OP_INVALIDOPCODE;
} | [
"public",
"static",
"int",
"getOpCode",
"(",
"String",
"opCodeName",
")",
"{",
"if",
"(",
"opCodeNameMap",
".",
"containsKey",
"(",
"opCodeName",
")",
")",
"return",
"opCodeNameMap",
".",
"get",
"(",
"opCodeName",
")",
";",
"return",
"OP_INVALIDOPCODE",
";",
... | Converts the given OpCodeName into an int | [
"Converts",
"the",
"given",
"OpCodeName",
"into",
"an",
"int"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/ScriptOpCodes.java#L418-L423 |
23,394 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/RedeemData.java | RedeemData.of | public static RedeemData of(ECKey key, Script redeemScript) {
checkArgument(ScriptPattern.isP2PKH(redeemScript)
|| ScriptPattern.isP2WPKH(redeemScript) || ScriptPattern.isP2PK(redeemScript));
return key != null ? new RedeemData(Collections.singletonList(key), redeemScript) : null;
} | java | public static RedeemData of(ECKey key, Script redeemScript) {
checkArgument(ScriptPattern.isP2PKH(redeemScript)
|| ScriptPattern.isP2WPKH(redeemScript) || ScriptPattern.isP2PK(redeemScript));
return key != null ? new RedeemData(Collections.singletonList(key), redeemScript) : null;
} | [
"public",
"static",
"RedeemData",
"of",
"(",
"ECKey",
"key",
",",
"Script",
"redeemScript",
")",
"{",
"checkArgument",
"(",
"ScriptPattern",
".",
"isP2PKH",
"(",
"redeemScript",
")",
"||",
"ScriptPattern",
".",
"isP2WPKH",
"(",
"redeemScript",
")",
"||",
"Scri... | Creates RedeemData for P2PKH, P2WPKH or P2PK input. Provided key is a single private key needed
to spend such inputs. | [
"Creates",
"RedeemData",
"for",
"P2PKH",
"P2WPKH",
"or",
"P2PK",
"input",
".",
"Provided",
"key",
"is",
"a",
"single",
"private",
"key",
"needed",
"to",
"spend",
"such",
"inputs",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/RedeemData.java#L59-L63 |
23,395 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelClientState.java | PaymentChannelClientState.isSettlementTransaction | public synchronized boolean isSettlementTransaction(Transaction tx) {
try {
tx.verify();
tx.getInput(0).verify(getContractInternal().getOutput(0));
return true;
} catch (VerificationException e) {
return false;
}
} | java | public synchronized boolean isSettlementTransaction(Transaction tx) {
try {
tx.verify();
tx.getInput(0).verify(getContractInternal().getOutput(0));
return true;
} catch (VerificationException e) {
return false;
}
} | [
"public",
"synchronized",
"boolean",
"isSettlementTransaction",
"(",
"Transaction",
"tx",
")",
"{",
"try",
"{",
"tx",
".",
"verify",
"(",
")",
";",
"tx",
".",
"getInput",
"(",
"0",
")",
".",
"verify",
"(",
"getContractInternal",
"(",
")",
".",
"getOutput",... | Returns true if the tx is a valid settlement transaction. | [
"Returns",
"true",
"if",
"the",
"tx",
"is",
"a",
"valid",
"settlement",
"transaction",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelClientState.java#L119-L127 |
23,396 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelClientState.java | PaymentChannelClientState.fakeSave | @VisibleForTesting synchronized void fakeSave() {
try {
wallet.commitTx(getContractInternal());
} catch (VerificationException e) {
throw new RuntimeException(e); // We created it
}
stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
} | java | @VisibleForTesting synchronized void fakeSave() {
try {
wallet.commitTx(getContractInternal());
} catch (VerificationException e) {
throw new RuntimeException(e); // We created it
}
stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
} | [
"@",
"VisibleForTesting",
"synchronized",
"void",
"fakeSave",
"(",
")",
"{",
"try",
"{",
"wallet",
".",
"commitTx",
"(",
"getContractInternal",
"(",
")",
")",
";",
"}",
"catch",
"(",
"VerificationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
... | Skips saving state in the wallet for testing | [
"Skips",
"saving",
"state",
"in",
"the",
"wallet",
"for",
"testing"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelClientState.java#L347-L354 |
23,397 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/SegwitAddress.java | SegwitAddress.encode | private static byte[] encode(int witnessVersion, byte[] witnessProgram) throws AddressFormatException {
byte[] convertedProgram = convertBits(witnessProgram, 0, witnessProgram.length, 8, 5, true);
byte[] bytes = new byte[1 + convertedProgram.length];
bytes[0] = (byte) (Script.encodeToOpN(witness... | java | private static byte[] encode(int witnessVersion, byte[] witnessProgram) throws AddressFormatException {
byte[] convertedProgram = convertBits(witnessProgram, 0, witnessProgram.length, 8, 5, true);
byte[] bytes = new byte[1 + convertedProgram.length];
bytes[0] = (byte) (Script.encodeToOpN(witness... | [
"private",
"static",
"byte",
"[",
"]",
"encode",
"(",
"int",
"witnessVersion",
",",
"byte",
"[",
"]",
"witnessProgram",
")",
"throws",
"AddressFormatException",
"{",
"byte",
"[",
"]",
"convertedProgram",
"=",
"convertBits",
"(",
"witnessProgram",
",",
"0",
","... | Helper for the above constructor. | [
"Helper",
"for",
"the",
"above",
"constructor",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/SegwitAddress.java#L71-L77 |
23,398 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/SegwitAddress.java | SegwitAddress.convertBits | private static byte[] convertBits(final byte[] in, final int inStart, final int inLen, final int fromBits,
final int toBits, final boolean pad) throws AddressFormatException {
int acc = 0;
int bits = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream(64);
final int maxv... | java | private static byte[] convertBits(final byte[] in, final int inStart, final int inLen, final int fromBits,
final int toBits, final boolean pad) throws AddressFormatException {
int acc = 0;
int bits = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream(64);
final int maxv... | [
"private",
"static",
"byte",
"[",
"]",
"convertBits",
"(",
"final",
"byte",
"[",
"]",
"in",
",",
"final",
"int",
"inStart",
",",
"final",
"int",
"inLen",
",",
"final",
"int",
"fromBits",
",",
"final",
"int",
"toBits",
",",
"final",
"boolean",
"pad",
")... | Helper for re-arranging bits into groups. | [
"Helper",
"for",
"re",
"-",
"arranging",
"bits",
"into",
"groups",
"."
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/SegwitAddress.java#L222-L249 |
23,399 | bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServerState.java | PaymentChannelServerState.makeUnsignedChannelContract | protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) {
Transaction tx = new Transaction(wallet.getParams());
if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) {
tx.addOutput(getTotalValue().subtract(valueToMe), LegacyAddress.fromKey(wallet.getParams(), get... | java | protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) {
Transaction tx = new Transaction(wallet.getParams());
if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) {
tx.addOutput(getTotalValue().subtract(valueToMe), LegacyAddress.fromKey(wallet.getParams(), get... | [
"protected",
"synchronized",
"SendRequest",
"makeUnsignedChannelContract",
"(",
"Coin",
"valueToMe",
")",
"{",
"Transaction",
"tx",
"=",
"new",
"Transaction",
"(",
"wallet",
".",
"getParams",
"(",
")",
")",
";",
"if",
"(",
"!",
"getTotalValue",
"(",
")",
".",
... | Create a payment transaction with valueToMe going back to us | [
"Create",
"a",
"payment",
"transaction",
"with",
"valueToMe",
"going",
"back",
"to",
"us"
] | 9cf13d29315014ed59cf4fc5944e5f227e8df9a6 | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelServerState.java#L221-L228 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.