opened
pinheadmz
username_0
Using the `wallet.send({ ...  rate: ... })` API and then mining blocks with `miner` I'm having trouble getting SegWit transactions confirmed when the fee is `== network.minRelay`. This does not happen to legacy transactions, but only when spending from SegWit outputs, I discovered the tx won't get included in a block unless I crank up the fee `* 10` !!
In Regtest, mining SegWit transactions requires much higher fee rate than legacy
issue
created
pinheadmz
username_0
More details...
I am having trouble identifying the problem as either being on the wallet side OR the miner side.

These transactions are getting marked as "free" here:
https://github.com/bcoin-org/bcoin/blob/master/lib/mining/template.js#L652
`item.free = entry.getDeltaFee() < policy.getMinFee(entry.size);`

In these `MempoolEntry`'s and `BlockEntry`'s for 1-in, 2-out tx Legacy vs. SegWit you can see that the `deltaFee` is just slightly less than the threshold.

SegWit: deltaFee = `140`, minFee = `141` 🚫
Legacy: deltaFee = `227`, minFee = `226` ✅

## MempoolEntry
### LEGACY:
```
MempoolEntry {
tx: { hash: 'd72312d610ff4f0c119c2000a93a824a514161a8627b8fdcba015aff032a1510',
   witnessHash: 'd72312d610ff4f0c119c2000a93a824a514161a8627b8fdcba015aff032a1510',
   size: 225,
   virtualSize: 225,
   value: '428.74997592',
   fee: '0.0',
   rate: '0.0',
   minFee: '0.00000225',
   height: -1,
   block: null,
   time: 0,
   date: null,
   index: -1,
   version: 1,
   inputs: [ [Object] ],
   outputs: [ [Object], [Object] ],
   locktime: 0 },
height: 433,
size: 225,
sigops: 8,
priority: 0,
fee: 227,
deltaFee: 227,
time: 1547349007,
value: 42874997819,
coinbase: false,
dependencies: false,
descFee: 227,
descSize: 225 }
```

### SEGWIT:
```
MempoolEntry {
  tx: { hash: 'e3bd52ea9417ae7b4fdbcc2e6e1e0abca2d048933367092fc3d5bd25d71ae96b',
   witnessHash: '77303d1e965147bf6af526c21266b98a1389d93cbc851e43405026e4d20635fd',
   size: 223,
   virtualSize: 141,
   value: '428.74997682',
   fee: '0.0',
   rate: '0.0',
   minFee: '0.00000141',
   height: -1,
   block: null,
   time: 0,
   date: null,
   index: -1,
   version: 1,
   inputs: [ [Object] ],
   outputs: [ [Object], [Object] ],
   locktime: 0 },
height: 433,
size: 141,
sigops: 1,
priority: 0,
fee: 140,
deltaFee: 140,
time: 1547349067,
value: 42874997822,
coinbase: false,
dependencies: false,
descFee: 140,
descSize: 141 }
```


## BlockEntry
### LEGACY:
```
 BlockEntry {
  tx: { hash: '6a664616a5f83988573c33cb24659aabf258e01e47858dfd6195bd9192b6a444',
     witnessHash: '6a664616a5f83988573c33cb24659aabf258e01e47858dfd6195bd9192b6a444',
     size: 225,
     virtualSize: 225,
     value: '428.74997592',
     fee: '0.0',
     rate: '0.0',
     minFee: '0.00000225',
     height: -1,
     block: null,
     time: 0,
     date: null,
     index: -1,
     version: 1,
     inputs: 
      [ { type: 'pubkeyhash',
          subtype: null,
          address: <Address: type=pubkeyhash version=-1 str=1227fG8w1yPNUcTVx2wvm6nFdRe6wDrtxd>,
          script: <Script: 0x47 0x304402202922bb580ba218b77ef2788bb6da517eec4db3af0c10303ccab99501c682351802203ab623da81ffab92aa89f3a5b50a34396218020e1e22088e040677187237340f01 0x21 0x034ccdc0b8452cabdf0532d44a25695bf3ba72a088c82521c14239b2e358be4738>,
          witness: <Witness: >,
          redeem: null,
          sequence: 4294967295,
          prevout: <Outpoint: d6f01d24fb77f2c1fc0765bd8a01de7c233270dffec3dd231e28927ab5064307/2>,
          coin: null } ],
     outputs: 
      [ { type: 'pubkeyhash',
          value: '0.00049792',
          script: <Script: OP_DUP OP_HASH160 0x14 0x2d940bb9bab9515b141b735021770ebd67f76e9d OP_EQUALVERIFY OP_CHECKSIG>,
          address: <Address: type=pubkeyhash version=-1 str=159zm32zxohaQL2u8LMnHiqGXM3F1GcMSj> },
        { type: 'pubkeyhash',
          value: '428.749478',
          script: <Script: OP_DUP OP_HASH160 0x14 0x2c9e5c5256feefc96e11897ac4f451befc89efe4 OP_EQUALVERIFY OP_CHECKSIG>,
          address: <Address: type=pubkeyhash version=-1 str=154vSXkGykNtqxggCzC64GqmDF3t4GVnUg> } ],
     locktime: 0 },
  hash: <Buffer 44 a4 b6 92 91 bd 95 61 fd 8d 85 47 1e e0 58 f2 ab 9a 65 24 cb 33 3c 57 88 39 f8 a5 16 46 66 6a>,
  fee: 227,
  rate: 1008,
  priority: 190555545,
  free: false,
  sigops: 8,
  descRate: 1008,
  depCount: 0 }
```

### SEGWIT:
```
BlockEntry {
  tx: { hash: '47fec1d7f188f5ba9947e9865c03d6d83b5a6cf0682ef4dd4958a5293cb15af8',
     witnessHash: '83a2a47fe6cab48bc817db9574730e9998896d28eb87c556b14f91111eb4a3ee',
     size: 223,
     virtualSize: 141,
     value: '428.74997682',
     fee: '0.0',
     rate: '0.0',
     minFee: '0.00000141',
     height: -1,
     block: null,
     time: 0,
     date: null,
     index: -1,
     version: 1,
     inputs: 
      [ { type: 'witnesspubkeyhash',
          subtype: null,
          address: <Address: type=witness version=0 str=bc1qf6agt2r555t3xnk0tf5yx3tuhlmav3rt9zx3up>,
          script: <Script: >,
          witness: <Witness: 3045022100c3c9ad19f43e3ee78cf88cd0e5b66b4ffc8384933d4444f682d569e7ee40e8b902203d7dc29ef1f7ff04662826b45a2e59230c533a2f798c1a2f88427ed7cb05459c01 030d484411e62e10c658e9dbd111ba220942394ca07becca3211890fee2aae6605>,
          redeem: null,
          sequence: 4294967295,
          prevout: <Outpoint: 89a45e292f4d7b997b48d89daf5e05a477c253913da52412c34c9da7a2958a31/4>,
          coin: null } ],
     outputs: 
      [ { type: 'witnesspubkeyhash',
          value: '0.00088535',
          script: <Script: OP_0 0x14 0x9511bf07603209b5854cfdfe6227ee8ec05621b1>,
          address: <Address: type=witness version=0 str=bc1qj5gm7pmqxgymtp2vlhlxyflw3mq9vgd3rlqs4r> },
        { type: 'witnesspubkeyhash',
          value: '428.74909147',
          script: <Script: OP_0 0x14 0x07639e97edcc9b3ff6b1c754156f5c8e7398a4e1>,
          address: <Address: type=witness version=0 str=bc1qqa3ea9ldejdnla43ca2p2m6u3eee3f8pyg3amu> } ],
     locktime: 0 },
  hash: <Buffer f8 5a b1 3c 29 a5 58 49 dd f4 2e 68 f0 6c 5a 3b d8 d6 03 5c 86 e9 47 99 ba f5 88 f1 d7 c1 fe 47>,
  fee: 140,
  rate: 992,
  priority: 304077998,
  free: true,
  sigops: 1,
  descRate: 992,
  depCount: 0 }
```
comment